aboutsummaryrefslogtreecommitdiff
path: root/src/provider/mod.rs
blob: 1ef6b0fa994cd4f3ef017f044edeb7c338365ab6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
pub mod gandi;

use std::net::{Ipv4Addr, Ipv6Addr};

use anyhow::Result;
use async_trait::async_trait;

#[async_trait]
pub trait DnsProvider: Send + Sync {
    fn provider(&self) -> &'static str;
    async fn update_a(
        &self,
        domain: &str,
        subdomain: Option<&str>,
        targets: &[Ipv4Addr],
    ) -> Result<()>;
    async fn update_aaaa(
        &self,
        domain: &str,
        subdomain: Option<&str>,
        targets: &[Ipv6Addr],
    ) -> Result<()>;
    async fn update_cname(&self, domain: &str, subdomain: Option<&str>, target: &str)
        -> Result<()>;
}

impl std::fmt::Debug for dyn DnsProvider {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
        write!(f, "DnsProvider({})", self.provider())
    }
}