Struct async_zeroconf::ServiceBrowserBuilder[][src]

pub struct ServiceBrowserBuilder { /* fields omitted */ }
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

Create a new ServiceBrowserBuilder for the specified service type

Set the timeout

Set the browser to close if no more Services are found.

Note

The browser can only detect the end of the Services if any are found. A timeout can be used in combination with closing on end to ensure that the browser will terminate.

Set the interface for service discovery rather than all

Set the domain for service discovery rather than all

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);
}

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.