pub struct ServiceDiscovery { /* private fields */ }Expand description
Main service discovery interface
Implementations§
Source§impl ServiceDiscovery
impl ServiceDiscovery
Sourcepub async fn new(config: DiscoveryConfig) -> Result<Self>
pub async fn new(config: DiscoveryConfig) -> Result<Self>
Sourcepub async fn discover_services(
&self,
protocol_type: Option<ProtocolType>,
) -> Result<Vec<ServiceInfo>>
pub async fn discover_services( &self, protocol_type: Option<ProtocolType>, ) -> Result<Vec<ServiceInfo>>
Discover services with optional protocol type filter
Sourcepub async fn discover_services_filtered(
&self,
service_types: Option<Vec<ServiceType>>,
protocol_type: Option<ProtocolType>,
) -> Result<Vec<ServiceInfo>>
pub async fn discover_services_filtered( &self, service_types: Option<Vec<ServiceType>>, protocol_type: Option<ProtocolType>, ) -> Result<Vec<ServiceInfo>>
Discover services with filtering by service types
This provides more granular control over service discovery than the basic
discover_services method.
§Arguments
service_types- Optional list of specific service types to discover. If None, uses all configured service types.protocol_type- Optional protocol filter. If None, uses all enabled protocols.
§Example
use auto_discovery::{ServiceDiscovery, types::{ServiceType, ProtocolType}};
// Discover only HTTP services using mDNS
let http_services = discovery.discover_services_filtered(
Some(vec![ServiceType::new("_http._tcp")?]),
Some(ProtocolType::Mdns)
).await?;
// Discover HTTP services using any protocol
let all_services = discovery.discover_services_filtered(
Some(vec![ServiceType::new("_http._tcp")?]),
None
).await?;Sourcepub async fn register_service(&self, service: ServiceInfo) -> Result<()>
pub async fn register_service(&self, service: ServiceInfo) -> Result<()>
Register a service
Sourcepub async fn unregister_service(&self, service: &ServiceInfo) -> Result<()>
pub async fn unregister_service(&self, service: &ServiceInfo) -> Result<()>
Unregister a service
Sourcepub async fn verify_service(&self, service: &ServiceInfo) -> Result<bool>
pub async fn verify_service(&self, service: &ServiceInfo) -> Result<bool>
Verify a service is still available
Sourcepub async fn get_discovered_services(&self) -> Vec<ServiceInfo>
pub async fn get_discovered_services(&self) -> Vec<ServiceInfo>
Get all discovered services
Sourcepub async fn get_registered_services(&self) -> Vec<ServiceInfo>
pub async fn get_registered_services(&self) -> Vec<ServiceInfo>
Get all registered services
Sourcepub async fn service_exists(&self, service_name: &str) -> bool
pub async fn service_exists(&self, service_name: &str) -> bool
Check if a service exists
Sourcepub async fn update_config(&mut self, config: DiscoveryConfig) -> Result<()>
pub async fn update_config(&mut self, config: DiscoveryConfig) -> Result<()>
Update discovery configuration
Auto Trait Implementations§
impl Freeze for ServiceDiscovery
impl !RefUnwindSafe for ServiceDiscovery
impl Send for ServiceDiscovery
impl Sync for ServiceDiscovery
impl Unpin 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