rsip_dns/
dns_client.rs

1use crate::records::{AddrRecord, NaptrRecord, SrvDomain, SrvRecord};
2use async_trait::async_trait;
3use rsip::{Domain, Error};
4
5/// This trait needs to be implemented by any dns client used inside the [Context](super::Context).
6/// rsip-dns provides a default implementation on top of [trust-dns](https://docs.rs/trust-dns-resolver/0.20.3/trust_dns_resolver/)
7/// behind the `trust-dns` feature flag. For more information take a look in the
8/// `trust_dns` module.
9///
10/// Note that whether [DnsClient::ip_lookup] queries for an A or an AAAA or both records is up
11/// to the DNS client used.
12#[async_trait]
13pub trait DnsClient: Clone + Sync + Send {
14    // returns an Option since RFC 3263 alg can continue even without this
15    async fn naptr_lookup(&self, domain: Domain) -> Option<NaptrRecord>;
16    // returns an Option since RFC 3263 alg can continue even without this
17    async fn srv_lookup(&self, domain: SrvDomain) -> Option<SrvRecord>;
18    async fn ip_lookup(&self, domain: Domain) -> Result<AddrRecord, Error>;
19}