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]
impl<UID: Uid> Service<UID>
pub fn new(event_tx: CrustEventSender<UID>, our_uid: UID) -> Res<Self>
[src]
pub fn new(event_tx: CrustEventSender<UID>, our_uid: UID) -> Res<Self>
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]
pub fn with_config(
event_tx: CrustEventSender<UID>,
config: Config,
our_uid: UID
) -> Res<Self>
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 Event
s from this
library.
pub fn set_accept_bootstrap(&self, accept: bool) -> Res<()>
[src]
pub fn set_accept_bootstrap(&self, accept: bool) -> Res<()>
Allow (or disallow) peers from bootstrapping off us.
pub fn start_service_discovery(&mut self)
[src]
pub fn start_service_discovery(&mut self)
Initialises Service Discovery module and starts listening for responses to our beacon broadcasts.
pub fn set_service_discovery_listen(&self, listen: bool)
[src]
pub fn set_service_discovery_listen(&self, listen: bool)
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]
pub fn get_peer_ip_addr(&self, peer_uid: &UID) -> Res<IpAddr>
Return the ip address of the peer.
pub fn is_peer_hard_coded(&self, peer_uid: &UID) -> bool
[src]
pub fn is_peer_hard_coded(&self, peer_uid: &UID) -> bool
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]
pub fn has_peers_on_lan(&self) -> bool
Check if we have peers on LAN
pub fn start_bootstrap(
&mut self,
blacklist: HashSet<SocketAddr>,
crust_user: CrustUser
) -> Res<()>
[src]
pub fn start_bootstrap(
&mut self,
blacklist: HashSet<SocketAddr>,
crust_user: CrustUser
) -> Res<()>
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]
pub fn stop_bootstrap(&mut self) -> Res<()>
Stop the bootstraping procedure explicitly
pub fn start_listening_tcp(&mut self) -> Res<()>
[src]
pub fn start_listening_tcp(&mut self) -> Res<()>
Starts accepting TCP connections. This is persistant until it errors out or is stopped explicitly.
pub fn stop_tcp_listener(&mut self) -> Res<()>
[src]
pub fn stop_tcp_listener(&mut self) -> Res<()>
Stops Listener explicitly and stops accepting TCP connections.
pub fn connect(
&self,
our_ci: PrivConnectionInfo<UID>,
their_ci: PubConnectionInfo<UID>
) -> Res<()>
[src]
pub fn connect(
&self,
our_ci: PrivConnectionInfo<UID>,
their_ci: PubConnectionInfo<UID>
) -> Res<()>
Connect to a peer. To call this method you must follow these steps:
- Generate a
PrivConnectionInfo
viaService::prepare_connection_info
. - Create a
PubConnectionInfo
viaPrivConnectionInfo::to_pub_connection_info
. - Swap
PubConnectionInfo
s out-of-band with the peer you are connecting to. - Call
Service::connect
using yourPrivConnectionInfo
and thePubConnectionInfo
obtained from the peer
pub fn disconnect(&self, peer_uid: &UID) -> bool
[src]
pub fn disconnect(&self, peer_uid: &UID) -> bool
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]
pub fn send(&self, peer_uid: &UID, msg: Vec<u8>, priority: Priority) -> Res<()>
Send data to a peer.
pub fn prepare_connection_info(&self, result_token: u32)
[src]
pub fn prepare_connection_info(&self, result_token: u32)
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]
pub fn is_connected(&self, peer_uid: &UID) -> bool
Check if we are connected to the given peer
pub fn id(&self) -> UID
[src]
pub fn id(&self) -> UID
Returns our ID.