[−][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.
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]
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 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
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>,