pub struct ConnectionPool { /* private fields */ }Expand description
Connection pool managing multiple peer connections.
Implementations§
Source§impl ConnectionPool
impl ConnectionPool
Sourcepub fn new(config: NetworkConfig) -> Self
pub fn new(config: NetworkConfig) -> Self
Create a new connection pool.
Sourcepub fn config(&self) -> &NetworkConfig
pub fn config(&self) -> &NetworkConfig
Get the network configuration.
Sourcepub async fn connection_count(&self) -> usize
pub async fn connection_count(&self) -> usize
Get the number of active connections.
Sourcepub async fn is_connected(&self, peer_id: &PeerId) -> bool
pub async fn is_connected(&self, peer_id: &PeerId) -> bool
Check if we’re connected to a peer.
Sourcepub async fn get_connection(&self, peer_id: &PeerId) -> Option<Connection>
pub async fn get_connection(&self, peer_id: &PeerId) -> Option<Connection>
Get connection info for a peer.
Sourcepub async fn add_connection(
&self,
peer_id: PeerId,
remote_addr: SocketAddr,
outbound: bool,
) -> Result<ConnectionId, TransportError>
pub async fn add_connection( &self, peer_id: PeerId, remote_addr: SocketAddr, outbound: bool, ) -> Result<ConnectionId, TransportError>
Add a connection to the pool.
Sourcepub async fn remove_connection(&self, peer_id: &PeerId) -> Option<Connection>
pub async fn remove_connection(&self, peer_id: &PeerId) -> Option<Connection>
Remove a connection from the pool.
Sourcepub async fn update_state(&self, peer_id: &PeerId, state: ConnectionState)
pub async fn update_state(&self, peer_id: &PeerId, state: ConnectionState)
Update connection state.
Sourcepub async fn record_sent(&self, peer_id: &PeerId)
pub async fn record_sent(&self, peer_id: &PeerId)
Record message sent.
Sourcepub async fn record_received(&self, peer_id: &PeerId)
pub async fn record_received(&self, peer_id: &PeerId)
Record message received.
Sourcepub async fn update_latency(&self, peer_id: &PeerId, latency: Duration)
pub async fn update_latency(&self, peer_id: &PeerId, latency: Duration)
Update latency measurement.
Sourcepub async fn get_idle_connections(&self, max_idle: Duration) -> Vec<PeerId>
pub async fn get_idle_connections(&self, max_idle: Duration) -> Vec<PeerId>
Get connections that have been idle too long.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ConnectionPool
impl !RefUnwindSafe for ConnectionPool
impl Send for ConnectionPool
impl Sync for ConnectionPool
impl Unpin for ConnectionPool
impl !UnwindSafe for ConnectionPool
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Returns whether the given value has been niched. Read more
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
Writes data to
out indicating that a T is niched.