pub trait IP2PConnection<M>:
Send
+ Sync
+ 'static {
// Required methods
fn send<'life0, 'async_trait>(
&'life0 self,
message: M,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn receive<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<DynIP2PFrame<M>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn rtt(&self) -> Option<Duration>;
// Provided methods
fn connection_type(&self) -> Option<ConnectionType> { ... }
fn connection_status_updates(&self) -> Option<DynConnectionStatusUpdates> { ... }
fn into_dyn(self) -> DynP2PConnection<M>
where Self: Sized { ... }
}Required Methods§
Sourcefn send<'life0, 'async_trait>(
&'life0 self,
message: M,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send<'life0, 'async_trait>(
&'life0 self,
message: M,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send a message over the connection. This is not required to be cancel-safe.
Takes &self so that the send and receive halves can be driven
concurrently. A send parked on transport flow control must never stop
the peer’s stream from being drained, or two peers that are both
sending an oversized message deadlock permanently.
While send and receive may run concurrently with each other, each
of them must have at most one caller at a time: a second concurrent
receive would steal frames from the first and silently reorder the
message stream.
Sourcefn receive<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<DynIP2PFrame<M>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn receive<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<DynIP2PFrame<M>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Receive a p2p frame from the connection. This is required to be
cancel-safe. See Self::send for the concurrency contract.
Provided Methods§
Sourcefn connection_type(&self) -> Option<ConnectionType>
fn connection_type(&self) -> Option<ConnectionType>
Get the transport type currently backing this live connection.
Sourcefn connection_status_updates(&self) -> Option<DynConnectionStatusUpdates>
fn connection_status_updates(&self) -> Option<DynConnectionStatusUpdates>
Subscribe to notifications that the live connection metadata may have changed.
Implementations should treat these as wake-ups only. The state machine
reads a fresh Self::connection_type and Self::rtt snapshot after
each notification. None means notifications are unsupported, while the
end of a returned stream means there will be no more notifications.