Expand description
async-zeroconf
is a crate to register ZeroConf
services and provides a
way of keeping the service alive using a reference to the service which
keeps the service registered until it is dropped. Internally, a tokio task
is spawned to check for events asynchronously.
§Examples
// Create a service description
let service = async_zeroconf::Service::new("Server", "_http._tcp", 80);
// Publish the service
let service_ref = service.publish().await?;
// Service kept alive until service_ref dropped
ServiceBrowserBuilder
and ServiceResolver
can be used to browse and
resolve services respectively.
Structs§
- OpType
OpType
is used to indicate the service type and the kind of operation associated with aServiceRef
. Primarily intended for debug.- Service
- Struct representing a
ZeroConf
service. This should be created with all the information that should be associated with the service and then thepublish
method can be used to register the service. TheServiceRef
returned frompublish
should be held for as long as the service should continue being advertised, once dropped the service will be deallocated. - Service
Browser - Struct used to get the results of a service browser which should be
constructed with a
ServiceBrowserBuilder
. - Service
Browser Builder ServiceBrowserBuilder
is used to browse for services. Once all the required information is added to theServiceBrowserBuilder
thebrowse
method will produce aServiceBrowser
which can be used as a stream, or theServiceBrowser::recv
method will produce the next service found.- Service
Ref - Struct to hold a published service, which keeps the service alive while a reference to it is held. When dropped the Service will be removed and any associated resources deallocated.
- Service
Resolver ServiceResolver
is used resolve a service obtained from aServiceBrowser
. 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.- TxtRecord
- Struct containing the entries for TXT records associated with a service
Enums§
- Bonjour
Error - An error from the Bonjour API
- Interface
- Enum to hold the Interface a service should be advertised on.
- OpKind
OpKind
represents the possible kinds of operation associated with aServiceRef
, primarily used for debug and obtained from theOpType
returned byServiceRef::op_type
.- Zeroconf
Error - Custom error holding any potential errors from publishing or browsing for services.
Traits§
- Process
Task - The
ProcessTask
trait represents the future that is returned from some functions that is awaited on to process events associated with a published service or a browse operation.