Struct async_zeroconf::ServiceResolver[][src]

pub struct ServiceResolver { /* fields omitted */ }
Expand description

ServiceResolver is used resolve a service obtained from a ServiceBrowser. Browsing does not obtain all information about a service, for example it doesn’t include port information, and resolving the service will fill this information in.

Note

This should be used only with services from a browse operation to ensure the interface and domain are set correctly.

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 {
    let resolved_service = async_zeroconf::ServiceResolver::r(&v).await?;
    println!("Service = {}", resolved_service);
}

Implementations

Create a new ServiceResolver with the default settings. The operation will have no timeout and it will check if the service to be resolved was from a browser.

Create a new ServiceResolver with a timeout.

Disable checking if services came from a browser

Static method to resolve the specified Service, the service must have been produced from a ServiceBrowser to ensure that the required information for the resolve operation is available.

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(service)) = services.recv().await {
    let resolved = async_zeroconf::ServiceResolver::r(&service).await?;
    println!("Service = {}", resolved);
}

Resolve the specified Service using this ServiceResolver. This does not consume the ServiceResolver so more services can be resolved using the same settings.

Examples

let mut browser = async_zeroconf::ServiceBrowserBuilder::new("_http._tcp");
let mut services = browser
    .timeout(tokio::time::Duration::from_secs(2))
    .browse()?;
let resolver = async_zeroconf::ServiceResolver::new();

while let Some(Ok(service)) = services.recv().await {
    let resolved = resolver.resolve(&service).await?;
    println!("Service = {}", resolved);
}

Resolve the specified Service using this ServiceResolver. The returned ProcessTask future must be awaited to process events associated with the browser.

If the resolve operation can be constructed, this will return a future which will produce the result of the resolve operation and a task which should be awaited on to handle any events associated with the resolving.

Note

This method is intended if more control is needed over how the task is spawned. ServiceResolver::resolve will automatically spawn the task.

Examples

let mut browser = async_zeroconf::ServiceBrowserBuilder::new("_http._tcp");
let mut services = browser
    .timeout(tokio::time::Duration::from_secs(2))
    .browse()?;
let resolver = async_zeroconf::ServiceResolver::new();

while let Some(Ok(service)) = services.recv().await {
    if let Ok((future, task)) = resolver.resolve_task(&service).await {
        tokio::spawn(task);
        let resolved = future.await?;
        println!("Service = {}", resolved);
    }
}

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

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 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.