[−][src]Struct pea2pea::Node
The central object responsible for handling all the connections.
Fields
config: NodeConfig
The node's configuration.
listening_addr: SocketAddr
The node's listening address.
known_peers: KnownPeers
Collects statistics related to the node's connections.
Implementations
impl Node
[src]
pub async fn new(config: Option<NodeConfig>) -> Result<Arc<Self>>
[src]
Returns a Node
wrapped in an Arc
.
pub async fn new_multiple(
count: usize,
config: Option<NodeConfig>
) -> Result<Vec<Arc<Self>>>
[src]
count: usize,
config: Option<NodeConfig>
) -> Result<Vec<Arc<Self>>>
Returns a vector of Node
s wrapped in Arc
s.
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]
self: &Arc<Self>,
addr: SocketAddr
) -> Result<()>
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]
&self,
addr: SocketAddr,
message: Bytes
) -> Result<()>
Sends the provided message to the specified, handshaken SocketAddr
.
pub async fn send_broadcast(&self, message: Bytes)
[src]
Broadcasts the provided message to all handshaken peers.
pub fn handshaken_addrs(&self) -> Vec<SocketAddr>
[src]
Returns a list containing addresses of handshaken connections.
pub fn register_sent_message(&self, from: SocketAddr, len: usize)
[src]
Updates the peer's statistics upon successful submission of a message.
pub fn register_received_message(&self, from: SocketAddr, len: usize)
[src]
Updates the peer's statistics upon successful receipt of a message.
pub fn register_failure(&self, from: SocketAddr)
[src]
Updates the peer's statistics upon a failure.
pub fn is_connected(&self, addr: SocketAddr) -> bool
[src]
Checks whether the provided address is connected, regardless of its handshake status.
pub fn num_connected(&self) -> usize
[src]
Returns the number of active connections, regardless of their handshake status.
pub fn is_handshaking(&self, addr: SocketAddr) -> bool
[src]
Checks whether a connection with the given address is currently in the process of handshaking.
pub fn is_handshaken(&self, addr: SocketAddr) -> bool
[src]
Checks whether a connection with the given address has been handshaken.
pub fn num_messages_sent(&self) -> usize
[src]
Returns the number of all sent messages.
pub fn num_messages_received(&self) -> usize
[src]
Returns the number of all received messages.
pub fn update_last_seen(&self, addr: SocketAddr)
[src]
Updates the "last seen" timestamp of a connection with the given address.
pub fn mark_as_handshaken(&self, addr: SocketAddr) -> Result<()>
[src]
Changes a connection's status from handshaking to handshaken.
pub fn inbound_messages(&self) -> Option<&Sender<(SocketAddr, InboundMessage)>>
[src]
Returns a Sender
for the channel handling all the
incoming messages, if Messaging is enabled.
pub fn set_inbound_messages(&self, sender: Sender<(SocketAddr, InboundMessage)>)
[src]
Sets up the Sender
for handling all incoming messages, as part of the Messaging protocol.
pub fn set_reading_closure(&self, closure: ReadingClosure)
[src]
Sets up the closure responsible for spawning per-connection tasks for handling inbound messages, as part of the Messaging protocol.
pub fn set_handshake_setup(&self, closures: HandshakeSetup)
[src]
Sets up the handshake-relevant objects, as part of the Handshaking protocol.
Auto Trait Implementations
impl !RefUnwindSafe for Node
[src]
impl Send for Node
[src]
impl Sync for Node
[src]
impl Unpin for Node
[src]
impl !UnwindSafe for Node
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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.
pub 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>,