pub struct DnsHandle { /* private fields */ }Expand description
Handle for managing DNS records after server is started
This handle can be cloned and used to add/remove records while the server is running.
Implementations§
Source§impl DnsHandle
impl DnsHandle
Sourcepub async fn add_record(
&self,
hostname: &str,
ip: IpAddr,
) -> Result<(), DnsError>
pub async fn add_record( &self, hostname: &str, ip: IpAddr, ) -> Result<(), DnsError>
Add a DNS record for a hostname to IP mapping
Creates an A record for IPv4 addresses and an AAAA record for IPv6 addresses.
§Errors
Returns DnsError::InvalidName if the hostname is invalid.
Sourcepub async fn remove_record(&self, hostname: &str) -> Result<bool, DnsError>
pub async fn remove_record(&self, hostname: &str) -> Result<bool, DnsError>
Remove DNS records for a hostname (both A and AAAA)
Tombstones both record types since we don’t track which type was stored.
§Errors
Returns DnsError::InvalidName if the hostname is invalid.
Sourcepub fn zone_origin(&self) -> &Name
pub fn zone_origin(&self) -> &Name
Get the zone origin
Sourcepub async fn lookup_a(&self, fqdn: &str) -> Option<IpAddr>
pub async fn lookup_a(&self, fqdn: &str) -> Option<IpAddr>
Look up the first A record for an absolute name directly against this handle’s in-memory authority, without any UDP roundtrip.
fqdn is treated as an absolute name (a trailing dot is optional). The
name MUST already be fully qualified within the server’s zone — this does
NOT apply resolv.conf-style search expansion. Returns the first A
record’s address, or None when no matching A record exists.
Intended for in-process callers and tests that need deterministic
resolution against the authority (the UDP DnsClient uses a blocking
sync client that can deadlock a current-thread tokio runtime).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for DnsHandle
impl !UnwindSafe for DnsHandle
impl Freeze for DnsHandle
impl Send for DnsHandle
impl Sync for DnsHandle
impl Unpin for DnsHandle
impl UnsafeUnpin for DnsHandle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more