pub struct AsyncDuplex<T> { /* private fields */ }
Expand description
A wrapper type around some “handle” that we want to perform asynchronous operations on, where that handle must implement AsyncDuplexSetup.
Implementations§
source§impl<T: AsyncDuplexSetup> AsyncDuplex<T>
impl<T: AsyncDuplexSetup> AsyncDuplex<T>
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consume the wrapper and return the underlying handle.
sourcepub async fn read_with<R>(
&self,
op: impl FnMut(&T) -> Result<R, T::ReadError>,
) -> Result<R, T::ReadError>
pub async fn read_with<R>( &self, op: impl FnMut(&T) -> Result<R, T::ReadError>, ) -> Result<R, T::ReadError>
Asynchronously run a read-like operation that will sleep if not ready. The closure to run
must return Result<_, T::ReadError>
, and should return Err(T::READ_WOULD_BLOCK)
if
the operation is not ready.
sourcepub async fn write_with<R>(
&self,
op: impl FnMut(&T) -> Result<R, T::WriteError>,
) -> Result<R, T::WriteError>
pub async fn write_with<R>( &self, op: impl FnMut(&T) -> Result<R, T::WriteError>, ) -> Result<R, T::WriteError>
Asynchronously run a write-like operation that will sleep if not ready. The closure to run
must return Result<_, T::WriteError>
, and should return Err(T::WRITE_WOULD_BLOCK)
if
the operation is not ready.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for AsyncDuplex<T>
impl<T> !ObjSafe for AsyncDuplex<T>
impl<T> RefUnwindSafe for AsyncDuplex<T>where
T: RefUnwindSafe,
impl<T> Send for AsyncDuplex<T>where
T: Send,
impl<T> Sync for AsyncDuplex<T>where
T: Sync,
impl<T> Unpin for AsyncDuplex<T>
impl<T> UnwindSafe for AsyncDuplex<T>where
T: UnwindSafe,
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