[][src]Struct pea2pea::Node

pub struct Node {
    pub config: NodeConfig,
    pub listening_addr: SocketAddr,
    pub stats: NodeStats,
    // some fields omitted
}

The central object responsible for handling all the connections.

Fields

config: NodeConfig

The node's configuration.

listening_addr: SocketAddr

The node's listening address.

stats: NodeStats

Collects statistics related to the node itself.

Implementations

impl Node[src]

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

Returns a Node wrapped in an Arc.

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

Returns the name assigned to the node.

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

Returns the tracing Span associated with the node.

pub async fn initiate_connection(
    self: &Arc<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 reading_handler(&self) -> Option<&ReadingHandler>[src]

Returns a reference to the reading handler, if the Reading protocol is enabled.

pub fn writing_handler(&self) -> Option<&WritingHandler>[src]

Returns a reference to the writing handler, if the Writing protocol is enabled.

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

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

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

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

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

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

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, 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.