Struct service_discovery::ServiceDiscovery
[−]
[src]
pub struct ServiceDiscovery<Reply: 'static + Encodable + Decodable + Send + Clone> { /* fields omitted */ }
ServiceDiscovery is a RAII API for the purposes of discovering peers on the local network. To stop the process of discovery completely, it is sufficient to drop the instance of this struct.
Methods
impl<Reply: 'static + Encodable + Decodable + Send + Clone> ServiceDiscovery<Reply>
[src]
fn new(port: u16, reply: Reply) -> Result<Self>
Obtain a new RAII instance of ServiceDiscovery. By default listening to peers searching for us is disabled.
fn new_with_generator<ReplyGen>(
port: u16,
generator: ReplyGen
) -> Result<ServiceDiscovery<Reply>> where
ReplyGen: FnMut() -> Reply + 'static + Send,
port: u16,
generator: ReplyGen
) -> Result<ServiceDiscovery<Reply>> where
ReplyGen: FnMut() -> Reply + 'static + Send,
Obtain a new RAII instance of ServiceDiscovery. By default listening to peers searching for
us is disabled. This function is similar to new
except that it takes a callback which
generates replies on demand. This is useful if the reply you need to send might change
throughout the lifetime of the ServiceDiscovery.
fn register_seek_peer_observer(&self, observer: Sender<Reply>) -> bool
Register a new observer to be notified whenever we successfully find peers by interrogating the network. Return value indicates acknowledgement of the request.
fn set_listen_for_peers(&self, listen: bool) -> bool
Enable or disable listening and responding to peers searching for us. This will correspondingly allow or disallow others from finding us by interrogating the network. Return value indicates acknowledgement of the request.
fn seek_peers(&self) -> bool
Interrogate the network to find peers. Return value indicates acknowledgement of the request.