pub struct NetworkManager {
pub nb_active_connections: u16,
pub connection_pool: HashMap<SocketAddr, PeerConnection>,
}
Expand description
Manages network connections and peer communication
Fields§
§nb_active_connections: u16
Number of currently active peer connections
connection_pool: HashMap<SocketAddr, PeerConnection>
Pool of active peer connections
Implementations§
Source§impl NetworkManager
impl NetworkManager
Sourcefn add_connection(&mut self, site_addr: SocketAddr, sender: Sender<Vec<u8>>)
fn add_connection(&mut self, site_addr: SocketAddr, sender: Sender<Vec<u8>>)
Adds a new peer connection to the connection pool
Sourcepub async fn create_connection(
&mut self,
site_addr: SocketAddr,
) -> Result<(), Box<dyn Error>>
pub async fn create_connection( &mut self, site_addr: SocketAddr, ) -> Result<(), Box<dyn Error>>
Establishes a new connection to a peer
Sourcepub fn remove_connection(&mut self, site_addr: &SocketAddr)
pub fn remove_connection(&mut self, site_addr: &SocketAddr)
Remove and destroy a connection
Sourcepub fn get_sender(&self, addr: &SocketAddr) -> Option<Sender<Vec<u8>>>
pub fn get_sender(&self, addr: &SocketAddr) -> Option<Sender<Vec<u8>>>
Returns the message sender for a specific peer address
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<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
§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Create an instance of this type from an initialization function
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Convert from a type to another type.
§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
§fn super_into(self) -> O
fn super_into(self) -> O
Convert from a type to another type.