pub struct DuplexStream { /* private fields */ }Expand description
An endpoint owns both half-streams. Share it with Arc; dropping the last owner releases buffers and wakes both ends. A cancelled operation transfers no bytes; a successful write transfers the entire chunk atomically.
Implementations§
Source§impl DuplexStream
impl DuplexStream
pub fn pair( capacity_per_direction: usize, ) -> Result<(Arc<Self>, Arc<Self>), Error>
pub async fn read( &self, max: usize, cancel: &CancelToken, ) -> Result<Vec<u8>, Error>
pub async fn write( &self, bytes: &[u8], cancel: &CancelToken, ) -> Result<(), Error>
Sourcepub fn shutdown_write(&self)
pub fn shutdown_write(&self)
Half-close: the peer drains queued bytes, then reads EOF. Receive stays open.
Sourcepub fn release(&self)
pub fn release(&self)
Full release: discard queues and fail all parked operations, at both ends.
Sourcepub fn readiness(&self) -> StreamReadiness
pub fn readiness(&self) -> StreamReadiness
Advisory snapshot; another consumer may change readiness before an operation.
Sourcepub async fn ready(
&self,
read: bool,
write: bool,
cancel: &CancelToken,
) -> Result<StreamReadiness, Error>
pub async fn ready( &self, read: bool, write: bool, cancel: &CancelToken, ) -> Result<StreamReadiness, Error>
Wait for receive data/EOF or transmit capacity. Specify only interests needed by the caller; writable sockets usually become ready immediately.
Sourcepub fn store(self: &Arc<Self>) -> StreamStore
pub fn store(self: &Arc<Self>) -> StreamStore
Mount this endpoint through the standard consuming stream protocol.
Trait Implementations§
Source§impl Drop for DuplexStream
impl Drop for DuplexStream
Auto Trait Implementations§
impl Freeze for DuplexStream
impl RefUnwindSafe for DuplexStream
impl Send for DuplexStream
impl Sync for DuplexStream
impl Unpin for DuplexStream
impl UnsafeUnpin for DuplexStream
impl UnwindSafe for DuplexStream
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