[][src]Struct pea2pea::Node

pub struct Node(_);

The central object responsible for handling all the connections.

Implementations

impl Node[src]

pub async fn new(config: Option<NodeConfig>) -> Result<Self>[src]

Creates a new Node optionally using a given NodeConfig.

pub fn name(&self) -> &str[src]

Returns the name assigned to the node.

pub fn config(&self) -> &NodeConfig[src]

Returns a reference to the node's config.

pub fn stats(&self) -> &NodeStats[src]

Returns a reference to the node's stats.

pub fn span(&self) -> &Span[src]

Returns the tracing Span associated with the node.

pub fn listening_addr(&self) -> SocketAddr[src]

Returns the node's listening address.

pub async fn connect(&self, addr: SocketAddr) -> Result<()>[src]

Connects to the provided SocketAddr.

pub fn disconnect(&self, addr: SocketAddr) -> bool[src]

Disconnects from the provided SocketAddr.

pub async fn send_direct_message(
    &self,
    addr: SocketAddr,
    message: Bytes
) -> Result<()>
[src]

Sends the provided message to the specified SocketAddr, as long as the Writing protocol is enabled.

pub async fn send_broadcast(&self, message: Bytes) -> Result<()>[src]

Broadcasts the provided message to all peers, as long as the Writing protocol is enabled.

pub fn connected_addrs(&self) -> Vec<SocketAddr>[src]

Returns a list containing addresses of active connections.

pub fn known_peers(&self) -> &KnownPeers[src]

Returns a reference to the collection of statistics of node's known peers.

pub fn is_connected(&self, addr: SocketAddr) -> bool[src]

Checks whether the provided address is connected.

pub fn num_connected(&self) -> usize[src]

Returns the number of active connections.

pub fn set_handshake_handler(&self, handler: ProtocolHandler)[src]

Sets up the handshake handler, as part of the Handshaking protocol.

pub fn set_reading_handler(&self, handler: ProtocolHandler)[src]

Sets up the reading handler, as part of enabling the Reading protocol.

pub fn set_writing_handler(&self, handler: ProtocolHandler)[src]

Sets up the writing handler, as part of enabling the Writing protocol.

pub fn shut_down(&self)[src]

Gracefully shuts the node down.

Methods from Deref<Target = Arc<InnerNode>>

Trait Implementations

impl Clone for Node[src]

impl Deref for Node[src]

type Target = Arc<InnerNode>

The resulting type after dereferencing.

Auto Trait Implementations

Blanket Implementations

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

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

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

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

impl<T> Instrument for T[src]

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.