Struct ServiceBrowserBuilder

Source
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

Source

pub fn new(service_type: &str) -> Self

Create a new ServiceBrowserBuilder for the specified service type

Source

pub fn timeout(&mut self, timeout: Duration) -> &mut Self

Set the timeout

Source

pub fn close_on_end(&mut self) -> &mut Self

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.

Source

pub fn interface(&mut self, interface: Interface) -> &mut Self

Set the interface for service discovery rather than all

Source

pub fn domain(&mut self, domain: String) -> &mut Self

Set the domain for service discovery rather than all

Source

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

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

Source§

fn clone(&self) -> ServiceBrowserBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ServiceBrowserBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for ServiceBrowserBuilder

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

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

impl PartialEq for ServiceBrowserBuilder

Source§

fn eq(&self, other: &ServiceBrowserBuilder) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for ServiceBrowserBuilder

Source§

impl StructuralPartialEq for ServiceBrowserBuilder

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.