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>

source

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.

source

pub fn from_shared(reader: Arc<RwLock<R>>) -> Self

Create a new pipe from a shareable Read type.

All Handle read operations delegate to reading from this underlying reader.

source

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> Clone for ReadPipe<R>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<R: Debug + Read + ReadReady> Debug for ReadPipe<R>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<&[u8]> for ReadPipe<Cursor<Vec<u8>>>

source§

fn from(r: &[u8]) -> Self

Converts to this type from the input type.
source§

impl From<&str> for ReadPipe<Cursor<String>>

source§

fn from(r: &str) -> Self

Converts to this type from the input type.
source§

impl From<String> for ReadPipe<Cursor<String>>

source§

fn from(r: String) -> Self

Converts to this type from the input type.
source§

impl From<Vec<u8, Global>> for ReadPipe<Cursor<Vec<u8>>>

source§

fn from(r: Vec<u8>) -> Self

Converts to this type from the input type.
source§

impl<R: Read + ReadReady + Any + Send + Sync> InputStream for ReadPipe<R>

source§

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,

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,

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,

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,

Test whether this stream is readable.
source§

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,

Vectored-I/O form of read.
source§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> GetSetFdFlags for T

source§

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,

Create a new SetFdFlags value for use with set_fd_flags. Read more
source§

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
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Pointee for T

§

type Pointer = u32

source§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_> ) -> Result<(), Error>

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more