pub struct Connection {
pub(crate) direction: ConnDirection,
conn: Conn<NetMsg, Error>,
disconnect_signal: Sender<Result<()>>,
protocol_events: Arc<EventEmitter<ProtocolID>>,
pub(crate) remote_endpoint: Endpoint,
listeners: HashMap<ProtocolID, EventListener<ProtocolID, ProtocolEvent>>,
}
Fields§
§direction: ConnDirection
§conn: Conn<NetMsg, Error>
§disconnect_signal: Sender<Result<()>>
§protocol_events: Arc<EventEmitter<ProtocolID>>
EventEmitter
responsible for sending events to the registered protocols.
remote_endpoint: Endpoint
§listeners: HashMap<ProtocolID, EventListener<ProtocolID, ProtocolEvent>>
Implementations§
Source§impl Connection
impl Connection
pub fn new( conn: Conn<NetMsg, Error>, signal: Sender<Result<()>>, direction: ConnDirection, remote_endpoint: Endpoint, ) -> Self
pub async fn send<T: Encode>( &self, protocol_id: ProtocolID, msg: T, ) -> Result<()>
pub async fn recv<P: Protocol>(&self) -> Result<ProtocolEvent>
Sourcepub async fn register_protocol(&mut self, protocol_id: String)
pub async fn register_protocol(&mut self, protocol_id: String)
Registers a listener for the given Protocol P
.
pub async fn emit_msg( &self, id: &ProtocolID, event: &ProtocolEvent, ) -> Result<()>
pub async fn recv_inner(&self) -> Result<NetMsg>
pub async fn send_inner(&self, msg: NetMsg) -> Result<()>
pub async fn disconnect(&self, res: Result<()>) -> Result<()>
Auto Trait Implementations§
impl Freeze for Connection
impl !RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl !Unpin for Connection
impl !UnwindSafe for Connection
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