Struct crust::Service[][src]

pub struct Service<UID: Uid> { /* fields omitted */ }

A structure representing all the Crust services. This is the main object through which crust is used.

Methods

impl<UID: Uid> Service<UID>
[src]

Construct a service. event_tx is the sending half of the channel which crust will send notifications on.

Constructs a service with the given config. User needs to create an asynchronous channel, and provide the sender half to this method. Receiver will receive all Events from this library.

Allow (or disallow) peers from bootstrapping off us.

Initialises Service Discovery module and starts listening for responses to our beacon broadcasts.

Enable (or disable) listening and responding to peers searching for us. This can be used to allow others to discover us on the local network.

Return the ip address of the peer.

Returns whether the given peer's IP is in the config file's hard-coded contacts list.

Check if we have peers on LAN

Start the bootstrapping procedure. It will auto terminate after indicating success or failure via the event channel.

Stop the bootstraping procedure explicitly

Starts accepting TCP connections. This is persistant until it errors out or is stopped explicitly.

Stops Listener explicitly and stops accepting TCP connections.

Connect to a peer. To call this method you must follow these steps:

  • Generate a PrivConnectionInfo via Service::prepare_connection_info.
  • Create a PubConnectionInfo via PrivConnectionInfo::to_pub_connection_info.
  • Swap PubConnectionInfos out-of-band with the peer you are connecting to.
  • Call Service::connect using your PrivConnectionInfo and the PubConnectionInfo obtained from the peer

Disconnect from the given peer and returns whether there was a connection at all.

Send data to a peer.

Generate connection info. The connection info is returned via the ConnectionInfoPrepared event on the event channel. Calling this method is the first step of connecting to another peer, see Service::connect for more info.

Check if we are connected to the given peer

Returns our ID.

Auto Trait Implementations

impl<UID> Send for Service<UID>

impl<UID> !Sync for Service<UID>