Skip to content

Commit

Permalink
add array impl
Browse files Browse the repository at this point in the history
  • Loading branch information
parkma99 committed Oct 28, 2024
1 parent 5d3d36f commit c69e9cd
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions rama-dns/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,36 @@ where
}
}

impl<R, E, const N: usize> DnsResolver for [R; N]
where
R: DnsResolver<Error = E> + Send,
E: Send + 'static,
{
type Error = DnsChainDomainResolveErr<E>;

async fn ipv4_lookup(&self, domain: Domain) -> Result<Vec<Ipv4Addr>, Self::Error> {
let mut errors = Vec::new();
for resolver in self {
match resolver.ipv4_lookup(domain.clone()).await {
Ok(ipv4s) => return Ok(ipv4s),
Err(err) => errors.push(err),
}
}
Err(DnsChainDomainResolveErr { errors })
}

async fn ipv6_lookup(&self, domain: Domain) -> Result<Vec<Ipv6Addr>, Self::Error> {
let mut errors = Vec::new();
for resolver in self {
match resolver.ipv6_lookup(domain.clone()).await {
Ok(ipv6s) => return Ok(ipv6s),
Err(err) => errors.push(err),
}
}
Err(DnsChainDomainResolveErr { errors })
}
}

macro_rules! impl_dns_resolver_either_either {
($id:ident, $($param:ident),+ $(,)?) => {
impl<$($param),+> DnsResolver for ::rama_core::combinators::$id<$($param),+>
Expand Down

0 comments on commit c69e9cd

Please sign in to comment.