pub(crate) struct SingleConnection {
send_queue: Arc<AsyncQueue<PeerNetMsg>>,
recv_queues: HashMap<ProtocolID, Arc<AsyncQueue<ProtocolEvent>>>,
}Expand description
TCP / TLS path: one shared writer drains send_queue; a single
reader demuxes incoming PeerNetMsgs into the matching recv_queues.
Fields§
§send_queue: Arc<AsyncQueue<PeerNetMsg>>§recv_queues: HashMap<ProtocolID, Arc<AsyncQueue<ProtocolEvent>>>Implementations§
Source§impl SingleConnection
impl SingleConnection
Sourcepub(crate) fn from_queued(
queued: QueuedConn,
negotiated: &HashSet<ProtocolID>,
task_group: &TaskGroup,
stop_reason_tx: Sender<Result<()>>,
) -> Self
pub(crate) fn from_queued( queued: QueuedConn, negotiated: &HashSet<ProtocolID>, task_group: &TaskGroup, stop_reason_tx: Sender<Result<()>>, ) -> Self
Spawn the writer + demux reader and return the connection.
Trait Implementations§
Source§impl Wire for SingleConnection
impl Wire for SingleConnection
Source§fn send<'life0, 'life1, 'async_trait>(
&'life0 self,
proto_id: &'life1 ProtocolID,
payload: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn send<'life0, 'life1, 'async_trait>(
&'life0 self,
proto_id: &'life1 ProtocolID,
payload: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Send pre-encoded payload bytes for
proto_id.Source§fn recv<'life0, 'life1, 'async_trait>(
&'life0 self,
proto_id: &'life1 ProtocolID,
) -> Pin<Box<dyn Future<Output = Result<ProtocolEvent>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn recv<'life0, 'life1, 'async_trait>(
&'life0 self,
proto_id: &'life1 ProtocolID,
) -> Pin<Box<dyn Future<Output = Result<ProtocolEvent>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Pop the next event for
proto_id. Blocks until a message
arrives or shutdown is broadcast.Source§fn shutdown<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn shutdown<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Graceful close. Pushes Shutdown to every recv queue and signals
the wire (transport-specific).
Source§fn setup<'life0, 'life1, 'async_trait>(
&'life0 self,
_task_group: &'life1 TaskGroup,
_stop_reason_tx: Sender<Result<()>>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn setup<'life0, 'life1, 'async_trait>(
&'life0 self,
_task_group: &'life1 TaskGroup,
_stop_reason_tx: Sender<Result<()>>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Opens what must be opened with the remote before the protocols
run, and starts its reader and writer tasks. Called once by
Peer::run. Only QUIC has such a step.Auto Trait Implementations§
impl !RefUnwindSafe for SingleConnection
impl !UnwindSafe for SingleConnection
impl Freeze for SingleConnection
impl Send for SingleConnection
impl Sync for SingleConnection
impl Unpin for SingleConnection
impl UnsafeUnpin for SingleConnection
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§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