Trait embedded_io::asynch::Write
source · [−]pub trait Write: Io {
type WriteFuture<'a>: Future<Output = Result<usize, Self::Error>>
where
Self: 'a;
type FlushFuture<'a>: Future<Output = Result<(), Self::Error>>
where
Self: 'a;
fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a>;
fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a>;
fn write_all<'a>(
&'a mut self,
buf: &'a [u8]
) -> impl Future<Output = Result<(), Self::Error>> { ... }
}
Available on crate feature
async
only.Expand description
Async writer.
Semantics are the same as std::io::Write
, check its documentation for details.
Required Associated Types
Future returned by write
.
Required Methods
Write a buffer into this writer, returning how many bytes were written.
fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a>
fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination.
Provided Methods
Implementations on Foreign Types
sourceimpl<T: ?Sized + Write> Write for &mut T
impl<T: ?Sized + Write> Write for &mut T
type WriteFuture<'a>
where
Self: 'a = impl Future<Output = Result<usize, <&'_ mut T as Io>::Error>>
fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a>
type FlushFuture<'a>
where
Self: 'a = impl Future<Output = Result<(), <&'_ mut T as Io>::Error>>
fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a>
sourceimpl Write for &mut [u8]
impl Write for &mut [u8]
Write is implemented for &mut [u8]
by copying into the slice, overwriting
its data.
Note that writing updates the slice to point to the yet unwritten part. The slice will be empty when it has been completely overwritten.
If the number of bytes to be written exceeds the size of the slice, write operations will
return short writes: ultimately, Ok(0)
; in this situation, write_all
returns an error of
kind ErrorKind::WriteZero
.
type WriteFuture<'a>
where
Self: 'a = impl Future<Output = Result<usize, <&'_ mut [u8] as Io>::Error>>
fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a>
type FlushFuture<'a>
where
Self: 'a = impl Future<Output = Result<(), <&'_ mut [u8] as Io>::Error>>
fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a>
sourceimpl<T: ?Sized + Write> Write for Box<T>
Available on crate features std
or alloc
only.
impl<T: ?Sized + Write> Write for Box<T>
Available on crate features
std
or alloc
only.type WriteFuture<'a>
where
Self: 'a = impl Future<Output = Result<usize, <Box<T, Global> as Io>::Error>>
fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a>
type FlushFuture<'a>
where
Self: 'a = impl Future<Output = Result<(), <Box<T, Global> as Io>::Error>>
fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a>
sourceimpl Write for Vec<u8>
Available on crate features std
or alloc
only.
impl Write for Vec<u8>
Available on crate features
std
or alloc
only.type WriteFuture<'a>
where
Self: 'a = impl Future<Output = Result<usize, <Vec<u8, Global> as Io>::Error>>
fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a>
type FlushFuture<'a>
where
Self: 'a = impl Future<Output = Result<(), <Vec<u8, Global> as Io>::Error>>
fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a>
Implementors
sourceimpl<T: AsyncWrite + Unpin + ?Sized> Write for FromTokio<T>
Available on crate feature tokio
only.
impl<T: AsyncWrite + Unpin + ?Sized> Write for FromTokio<T>
Available on crate feature
tokio
only.sourceimpl<T: AsyncWrite + Unpin + ?Sized> Write for FromFutures<T>
Available on crate feature futures
only.
impl<T: AsyncWrite + Unpin + ?Sized> Write for FromFutures<T>
Available on crate feature
futures
only.