Struct wasmtime_wasi::preview2::pipe::ReadPipe
source · pub struct ReadPipe<R: Read + ReadReady> { /* private fields */ }
Expand description
A virtual pipe read end.
This reads from a source that implements the Read
trait. It
also requires the ReadReady
trait, which is implemented for many
popular Read
-implementing types and is easy to implemented for new
types.
A variety of From
impls are provided so that common pipe types are
easy to create. For example:
use wasmtime_wasi::preview2::{pipe::ReadPipe, WasiCtx};
let stdin = ReadPipe::from("hello from stdin!");
let builder = WasiCtx::builder().set_stdin(stdin);
Implementations§
source§impl<R: Read + ReadReady> ReadPipe<R>
impl<R: Read + ReadReady> ReadPipe<R>
sourcepub fn new(r: R) -> Self
pub fn new(r: R) -> Self
Create a new pipe from a Read
type.
All Handle
read operations delegate to reading from this underlying reader.
Create a new pipe from a shareable Read
type.
All Handle
read operations delegate to reading from this underlying reader.
sourcepub fn try_into_inner(self) -> Result<R, Self>
pub fn try_into_inner(self) -> Result<R, Self>
Try to convert this ReadPipe<R>
back to the underlying R
type.
This will fail with Err(self)
if multiple references to the underlying R
exist.
Trait Implementations§
source§impl<R: Read + ReadReady + Any + Send + Sync> InputStream for ReadPipe<R>
impl<R: Read + ReadReady + Any + Send + Sync> InputStream for ReadPipe<R>
fn as_any(&self) -> &dyn Any
source§fn num_ready_bytes<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn num_ready_bytes<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Return the number of bytes that may be read without blocking.
source§fn read<'life0, 'life1, 'async_trait>(
&'life0 mut self,
buf: &'life1 mut [u8]
) -> Pin<Box<dyn Future<Output = Result<(u64, bool), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn read<'life0, 'life1, 'async_trait>( &'life0 mut self, buf: &'life1 mut [u8] ) -> Pin<Box<dyn Future<Output = Result<(u64, bool), Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Read bytes. On success, returns a pair holding the number of bytes read
and a flag indicating whether the end of the stream was reached.
source§fn skip<'life0, 'async_trait>(
&'life0 mut self,
nelem: u64
) -> Pin<Box<dyn Future<Output = Result<(u64, bool), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn skip<'life0, 'async_trait>( &'life0 mut self, nelem: u64 ) -> Pin<Box<dyn Future<Output = Result<(u64, bool), Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Read bytes from a stream and discard them.
source§fn readable<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn readable<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Test whether this stream is readable.
source§fn pollable_read(&self) -> Option<BorrowedFd<'_>>
fn pollable_read(&self) -> Option<BorrowedFd<'_>>
If this stream is reading from a host file descriptor, return it so
that it can be polled with a host poll.
source§fn read_vectored<'a, 'life0, 'life1, 'async_trait>(
&'life0 mut self,
_bufs: &'life1 mut [IoSliceMut<'a>]
) -> Pin<Box<dyn Future<Output = Result<(u64, bool), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn read_vectored<'a, 'life0, 'life1, 'async_trait>( &'life0 mut self, _bufs: &'life1 mut [IoSliceMut<'a>] ) -> Pin<Box<dyn Future<Output = Result<(u64, bool), Error>> + Send + 'async_trait>>where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Vectored-I/O form of
read
.source§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
Test whether vectored I/O reads are known to be optimized in the
underlying implementation.
Auto Trait Implementations§
impl<R> RefUnwindSafe for ReadPipe<R>
impl<R> Send for ReadPipe<R>where R: Send + Sync,
impl<R> Sync for ReadPipe<R>where R: Send + Sync,
impl<R> Unpin for ReadPipe<R>
impl<R> UnwindSafe for ReadPipe<R>
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
source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where T: AsFilelike,
Query the “status” flags for the
self
file descriptor.source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where T: AsFilelike,
source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where T: AsFilelike,
Set the “status” flags for the
self
file descriptor. Read more