pub struct ServiceDiscovery { /* private fields */ }Expand description
Service discovery with DNS
Implementations§
Source§impl ServiceDiscovery
impl ServiceDiscovery
Sourcepub fn new(dns_server_addr: SocketAddr) -> Self
pub fn new(dns_server_addr: SocketAddr) -> Self
Create a new service discovery instance
Sourcepub async fn register(&self, name: &str, ip: IpAddr)
pub async fn register(&self, name: &str, ip: IpAddr)
Register a service (stores locally, does not update DNS server)
Sourcepub async fn resolve(&self, name: &str) -> Option<IpAddr>
pub async fn resolve(&self, name: &str) -> Option<IpAddr>
Resolve a service to an IP address
Checks the local cache first, then queries the DNS server for both A (IPv4) and AAAA (IPv6) records.
Sourcepub async fn unregister(&self, name: &str)
pub async fn unregister(&self, name: &str)
Unregister a service
Sourcepub async fn list_services(&self) -> Vec<String>
pub async fn list_services(&self) -> Vec<String>
List all registered services
Sourcepub fn dns_server(&self) -> SocketAddr
pub fn dns_server(&self) -> SocketAddr
Get the DNS server address
Auto Trait Implementations§
impl !Freeze for ServiceDiscovery
impl !RefUnwindSafe for ServiceDiscovery
impl Send for ServiceDiscovery
impl Sync for ServiceDiscovery
impl Unpin for ServiceDiscovery
impl UnsafeUnpin for ServiceDiscovery
impl !UnwindSafe for ServiceDiscovery
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
Mutably borrows from an owned value. Read more