pub struct NetworkManager { /* private fields */ }Expand description
Comprehensive network manager for P2P operations
Implementations§
Source§impl NetworkManager
impl NetworkManager
Sourcepub fn with_config(config: NetworkConfig) -> Self
pub fn with_config(config: NetworkConfig) -> Self
Create new network manager with custom configuration
Sourcepub async fn initialize(&mut self) -> Result<(), NetworkError>
pub async fn initialize(&mut self) -> Result<(), NetworkError>
Initialize the network manager
Sourcepub async fn connect_peer(
&self,
_peer_address: &str,
) -> Result<LibP2PPeerId, NetworkError>
pub async fn connect_peer( &self, _peer_address: &str, ) -> Result<LibP2PPeerId, NetworkError>
Connect to a peer
Sourcepub async fn disconnect_peer(
&self,
peer_id: &LibP2PPeerId,
) -> Result<(), NetworkError>
pub async fn disconnect_peer( &self, peer_id: &LibP2PPeerId, ) -> Result<(), NetworkError>
Disconnect from a peer
Sourcepub async fn send_message(
&self,
peer_id: &LibP2PPeerId,
data: Vec<u8>,
) -> Result<(), NetworkError>
pub async fn send_message( &self, peer_id: &LibP2PPeerId, data: Vec<u8>, ) -> Result<(), NetworkError>
Send message to a peer
Sourcepub async fn get_connected_peers(&self) -> Vec<LibP2PPeerId>
pub async fn get_connected_peers(&self) -> Vec<LibP2PPeerId>
Get list of connected peers
Sourcepub async fn get_peer_metadata(
&self,
peer_id: &LibP2PPeerId,
) -> Option<PeerMetadata>
pub async fn get_peer_metadata( &self, peer_id: &LibP2PPeerId, ) -> Option<PeerMetadata>
Get peer metadata
Sourcepub async fn get_network_stats(&self) -> NetworkStats
pub async fn get_network_stats(&self) -> NetworkStats
Get network statistics
Sourcepub async fn add_trusted_peer(&self, peer_id: LibP2PPeerId)
pub async fn add_trusted_peer(&self, peer_id: LibP2PPeerId)
Add peer to trusted list
Sourcepub async fn blacklist_peer(&self, peer_id: LibP2PPeerId)
pub async fn blacklist_peer(&self, peer_id: LibP2PPeerId)
Blacklist a peer
Sourcepub async fn start_discovery(&mut self) -> Result<(), NetworkError>
pub async fn start_discovery(&mut self) -> Result<(), NetworkError>
Start peer discovery
Sourcepub async fn shutdown(&mut self) -> Result<(), NetworkError>
pub async fn shutdown(&mut self) -> Result<(), NetworkError>
Stop the network manager
Sourcepub fn local_peer_id(&self) -> Option<LibP2PPeerId>
pub fn local_peer_id(&self) -> Option<LibP2PPeerId>
Get the local peer ID
Sourcepub async fn maintenance(&self)
pub async fn maintenance(&self)
Perform maintenance tasks
Sourcepub fn get_nat_info(&self) -> Option<NatInfo>
pub fn get_nat_info(&self) -> Option<NatInfo>
Get NAT information
Sourcepub async fn create_port_mapping(
&self,
local_port: u16,
external_port: u16,
protocol: PortMappingProtocol,
) -> Result<PortMapping, NetworkError>
pub async fn create_port_mapping( &self, local_port: u16, external_port: u16, protocol: PortMappingProtocol, ) -> Result<PortMapping, NetworkError>
Create port mapping
Sourcepub fn get_nat_traversal_stats(&self) -> Option<NatTraversalStats>
pub fn get_nat_traversal_stats(&self) -> Option<NatTraversalStats>
Get NAT traversal statistics
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NetworkManager
impl !RefUnwindSafe for NetworkManager
impl Send for NetworkManager
impl Sync for NetworkManager
impl Unpin for NetworkManager
impl !UnwindSafe for NetworkManager
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more