pub struct Connection { /* private fields */ }Implementations§
Source§impl Connection
impl Connection
Sourcepub fn id(&self) -> ConnectionId
pub fn id(&self) -> ConnectionId
Returns connection id.
Sourcepub fn remote_addr(&self) -> SocketAddr
pub fn remote_addr(&self) -> SocketAddr
Returns remote peer address.
Sourcepub fn metadata(&self) -> ConnectionMetadata
pub fn metadata(&self) -> ConnectionMetadata
Returns immutable metadata snapshot.
Sourcepub fn close_reason(&self) -> Option<ConnectionCloseReason>
pub fn close_reason(&self) -> Option<ConnectionCloseReason>
Returns close reason if connection is closed.
Sourcepub async fn send_bytes(
&self,
payload: impl Into<Bytes>,
) -> Result<(), SendQueueError>
pub async fn send_bytes( &self, payload: impl Into<Bytes>, ) -> Result<(), SendQueueError>
Sends bytes using default send options.
Sourcepub async fn send(
&self,
payload: impl AsRef<[u8]>,
) -> Result<(), SendQueueError>
pub async fn send( &self, payload: impl AsRef<[u8]>, ) -> Result<(), SendQueueError>
Sends borrowed bytes, copying into an owned payload buffer.
Sourcepub async fn send_compat(
&self,
stream: &[u8],
_immediate: bool,
) -> Result<(), SendQueueError>
pub async fn send_compat( &self, stream: &[u8], _immediate: bool, ) -> Result<(), SendQueueError>
Compatibility helper matching stream-like send signatures.
Sourcepub async fn recv_bytes(&mut self) -> Result<Bytes, RecvError>
pub async fn recv_bytes(&mut self) -> Result<Bytes, RecvError>
Receives next payload as zero-copy Bytes.
Sourcepub async fn recv(&mut self) -> Result<Vec<u8>, RecvError>
pub async fn recv(&mut self) -> Result<Vec<u8>, RecvError>
Receives next payload as owned Vec<u8>.
Sourcepub fn into_io(self) -> ConnectionIo
pub fn into_io(self) -> ConnectionIo
Converts into Tokio AsyncRead/AsyncWrite adapter.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Connection
impl !RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl UnsafeUnpin for Connection
impl !UnwindSafe for Connection
Blanket Implementations§
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