pub struct ServiceBrowserBuilder { /* private fields */ }
Expand description
ServiceBrowserBuilder
is used to browse for services. Once all the
required information is added to the ServiceBrowserBuilder
the
browse
method will produce a
ServiceBrowser
which can be used as a stream, or the
ServiceBrowser::recv
method will produce the next service found.
§Note
This does not resolve the services so does not contain all information
associated with the service. A further resolve operation is required to
fully populate the service. This can be done with a ServiceResolver
.
Alternatively, the ServiceBrowser::recv_resolve
method can be
used to resolve the services inline, or ServiceBrowser::resolving
used
to convert the stream into one that resolves services before returning
them.
§Examples
let mut browser = async_zeroconf::ServiceBrowserBuilder::new("_http._tcp");
let mut services = browser
.timeout(tokio::time::Duration::from_secs(2))
.browse()?;
while let Some(v) = services.recv().await {
println!("Service = {:?}", v);
}
Implementations§
Source§impl ServiceBrowserBuilder
impl ServiceBrowserBuilder
Sourcepub fn new(service_type: &str) -> Self
pub fn new(service_type: &str) -> Self
Create a new ServiceBrowserBuilder
for the specified service type
Sourcepub fn close_on_end(&mut self) -> &mut Self
pub fn close_on_end(&mut self) -> &mut Self
Sourcepub fn interface(&mut self, interface: Interface) -> &mut Self
pub fn interface(&mut self, interface: Interface) -> &mut Self
Set the interface for service discovery rather than all
Sourcepub fn domain(&mut self, domain: String) -> &mut Self
pub fn domain(&mut self, domain: String) -> &mut Self
Set the domain for service discovery rather than all
Sourcepub fn browse(&self) -> Result<ServiceBrowser, ZeroconfError>
pub fn browse(&self) -> Result<ServiceBrowser, ZeroconfError>
Start the browsing operation, which will continue until the specified
timeout or until the ServiceBrowser
is dropped.
§Examples
let mut browser = async_zeroconf::ServiceBrowserBuilder::new("_http._tcp");
let mut services = browser
.timeout(tokio::time::Duration::from_secs(2))
.browse()?;
while let Some(Ok(v)) = services.recv().await {
println!("Service = {:?}", v);
}
Sourcepub fn browse_task(
&self,
) -> Result<(ServiceBrowser, impl ProcessTask), ZeroconfError>
pub fn browse_task( &self, ) -> Result<(ServiceBrowser, impl ProcessTask), ZeroconfError>
Start the browsing operation, which will continue until the specified
timeout or until the ServiceBrowser
is dropped. The returned
ProcessTask
future must be awaited to process events associated with
the browser.
§Note
This method is intended if more control is needed over how the task
is spawned. ServiceBrowserBuilder::browse
will automatically spawn
the task.
§Examples
let mut browser = async_zeroconf::ServiceBrowserBuilder::new("_http._tcp");
let (mut services, task) = browser
.timeout(tokio::time::Duration::from_secs(2))
.browse_task()?;
tokio::spawn(task);
while let Some(Ok(v)) = services.recv().await {
println!("Service = {:?}", v);
}
Trait Implementations§
Source§impl Clone for ServiceBrowserBuilder
impl Clone for ServiceBrowserBuilder
Source§fn clone(&self) -> ServiceBrowserBuilder
fn clone(&self) -> ServiceBrowserBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more