Struct pea2pea::Node [−][src]
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]
&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 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
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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut 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.
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>,