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,
proto_ids: impl IntoIterator<Item = ProtocolID>,
task_group: &TaskGroup,
stop_chan: Sender<Result<()>>,
) -> Self
pub(crate) fn from_queued( queued: QueuedConn, proto_ids: impl IntoIterator<Item = ProtocolID>, task_group: &TaskGroup, stop_chan: Sender<Result<()>>, ) -> Self
Spawn the writer + demux reader and return the connection.
Trait Implementations§
Source§impl PeerConnection for SingleConnection
impl PeerConnection 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.Auto Trait Implementations§
impl Freeze for SingleConnection
impl !RefUnwindSafe for SingleConnection
impl Send for SingleConnection
impl Sync for SingleConnection
impl Unpin for SingleConnection
impl UnsafeUnpin for SingleConnection
impl !UnwindSafe 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