[−][src]Struct crust::Service
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]
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]
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]
&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]
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]
&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]
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
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Typeable for T where
T: Any,
T: Any,
impl<T> UnsafeAny for T where
T: Any,
T: Any,