wasi_common::pipe

Struct ReadPipe

Source
pub struct ReadPipe<R: Read> { /* private fields */ }
Expand description

A virtual pipe read end.

A variety of From impls are provided so that common pipe types are easy to create. For example:

use wasi_common::{pipe::ReadPipe, WasiCtx, Table};
let stdin = ReadPipe::from("hello from stdin!");
// Brint these instances from elsewhere (e.g. wasi-cap-std-sync):
let random = todo!();
let clocks = todo!();
let sched = todo!();
let table = Table::new();
let mut ctx = WasiCtx::new(random, clocks, sched, table);
ctx.set_stdin(Box::new(stdin.clone()));

Implementations§

Source§

impl<R: Read> 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> 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> 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>> for ReadPipe<Cursor<Vec<u8>>>

Source§

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

Converts to this type from the input type.
Source§

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

Source§

fn as_any(&self) -> &dyn Any

Source§

fn get_filetype<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<FileType, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn read_vectored<'a, 'life0, 'life1, 'async_trait>( &'life0 self, bufs: &'life1 mut [IoSliceMut<'a>], ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn pollable(&self) -> Option<BorrowedFd<'_>>

Source§

fn isatty(&self) -> bool

Source§

fn sock_accept<'life0, 'async_trait>( &'life0 self, _fdflags: FdFlags, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn WasiFile>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn sock_recv<'a, 'life0, 'life1, 'async_trait>( &'life0 self, _ri_data: &'life1 mut [IoSliceMut<'a>], _ri_flags: RiFlags, ) -> Pin<Box<dyn Future<Output = Result<(u64, RoFlags), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn sock_send<'a, 'life0, 'life1, 'async_trait>( &'life0 self, _si_data: &'life1 [IoSlice<'a>], _si_flags: SiFlags, ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn sock_shutdown<'life0, 'async_trait>( &'life0 self, _how: SdFlags, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn datasync<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn sync<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn get_fdflags<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<FdFlags, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn set_fdflags<'life0, 'async_trait>( &'life0 mut self, _flags: FdFlags, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn get_filestat<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Filestat, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn set_filestat_size<'life0, 'async_trait>( &'life0 self, _size: u64, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn advise<'life0, 'async_trait>( &'life0 self, _offset: u64, _len: u64, _advice: Advice, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn set_times<'life0, 'async_trait>( &'life0 self, _atime: Option<SystemTimeSpec>, _mtime: Option<SystemTimeSpec>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn read_vectored_at<'a, 'life0, 'life1, 'async_trait>( &'life0 self, _bufs: &'life1 mut [IoSliceMut<'a>], _offset: u64, ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn write_vectored<'a, 'life0, 'life1, 'async_trait>( &'life0 self, _bufs: &'life1 [IoSlice<'a>], ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn write_vectored_at<'a, 'life0, 'life1, 'async_trait>( &'life0 self, _bufs: &'life1 [IoSlice<'a>], _offset: u64, ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn seek<'life0, 'async_trait>( &'life0 self, _pos: SeekFrom, ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn peek<'life0, 'life1, 'async_trait>( &'life0 self, _buf: &'life1 mut [u8], ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn num_ready_bytes(&self) -> Result<u64, Error>

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,

Source§

fn writable<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Auto Trait Implementations§

§

impl<R> Freeze for ReadPipe<R>

§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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 T
where 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

Source§

type Pointer = u32

Source§

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

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

Source§

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