[][src]Struct crust::Service

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]

pub fn new(event_tx: CrustEventSender<UID>, our_uid: UID) -> Res<Self>[src]

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

pub fn with_config(
    event_tx: CrustEventSender<UID>,
    config: Config,
    our_uid: UID
) -> Res<Self>
[src]

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.

pub fn set_accept_bootstrap(&self, accept: bool) -> Res<()>[src]

Allow (or disallow) peers from bootstrapping off us.

pub fn start_service_discovery(&mut self)[src]

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

pub fn set_service_discovery_listen(&self, listen: bool)[src]

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.

pub fn get_peer_ip_addr(&self, peer_uid: &UID) -> Res<IpAddr>[src]

Return the ip address of the peer.

pub fn is_peer_hard_coded(&self, peer_uid: &UID) -> bool[src]

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

pub fn has_peers_on_lan(&self) -> bool[src]

Check if we have peers on LAN

pub fn start_bootstrap(
    &mut self,
    blacklist: HashSet<SocketAddr>,
    crust_user: CrustUser
) -> Res<()>
[src]

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

pub fn stop_bootstrap(&mut self) -> Res<()>[src]

Stop the bootstraping procedure explicitly

pub fn start_listening_tcp(&mut self) -> Res<()>[src]

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

pub fn stop_tcp_listener(&mut self) -> Res<()>[src]

Stops Listener explicitly and stops accepting TCP connections.

pub fn connect(
    &self,
    our_ci: PrivConnectionInfo<UID>,
    their_ci: PubConnectionInfo<UID>
) -> Res<()>
[src]

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

pub fn disconnect(&self, peer_uid: &UID) -> bool[src]

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

pub fn send(&self, peer_uid: &UID, msg: Vec<u8>, priority: Priority) -> Res<()>[src]

Send data to a peer.

pub fn prepare_connection_info(&self, result_token: u32)[src]

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.

pub fn is_connected(&self, peer_uid: &UID) -> bool[src]

Check if we are connected to the given peer

pub fn id(&self) -> UID[src]

Returns our ID.

Auto Trait Implementations

impl<UID> Send for Service<UID>

impl<UID> !Sync for Service<UID>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Typeable for T where
    T: Any

fn get_type(&self) -> TypeId

Get the TypeId of this object.

impl<T> UnsafeAny for T where
    T: Any