Struct wasi_common::pipe::WritePipe[][src]

pub struct WritePipe<W: Write> { /* fields omitted */ }
Expand description

A virtual pipe write end.

use wasi_common::{pipe::WritePipe, WasiCtx, Table};
let stdout = WritePipe::new_in_memory();
// Brint these instances from elsewhere (e.g. wasi-cap-std-sync):
let random = todo!();
let clocks = todo!();
let sched = todo!();
let table = Rc::new(RefCell::new(Table::new()));
let mut ctx = WasiCtx::new(random, clocks, sched, table);
ctx.set_stdout(Box::new(stdout.clone()));
// use ctx in an instance, then make sure it is dropped:
drop(ctx);
let contents: Vec<u8> = stdout.try_into_inner().expect("sole remaining reference to WritePipe").into_inner();
println!("contents of stdout: {:?}", contents);

Implementations

impl<W: Write> WritePipe<W>[src]

pub fn new(w: W) -> Self[src]

Create a new pipe from a Write type.

All Handle write operations delegate to writing to this underlying writer.

pub fn from_shared(writer: Arc<RwLock<W>>) -> Self[src]

Create a new pipe from a shareable Write type.

All Handle write operations delegate to writing to this underlying writer.

pub fn try_into_inner(self) -> Result<W, Self>[src]

Try to convert this WritePipe<W> back to the underlying W type.

This will fail with Err(self) if multiple references to the underlying W exist.

impl WritePipe<Cursor<Vec<u8>>>[src]

pub fn new_in_memory() -> Self[src]

Create a new writable virtual pipe backed by a Vec<u8> buffer.

Trait Implementations

impl<W: Write> Clone for WritePipe<W>[src]

fn clone(&self) -> Self[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<W: Debug + Write> Debug for WritePipe<W>[src]

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

Formats the value using the given formatter. Read more

impl<W: Write + Any + Send + Sync> WasiFile for WritePipe<W>[src]

fn as_any(&self) -> &dyn Any[src]

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

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

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

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

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

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

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

fn advise<'life0, 'async_trait>(
    &'life0 self,
    offset: u64,
    len: u64,
    advice: Advice
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

fn allocate<'life0, 'async_trait>(
    &'life0 self,
    offset: u64,
    len: u64
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

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

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>> + 'async_trait>> where
    'a: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

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

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>> + 'async_trait>> where
    'a: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

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

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

fn set_times<'life0, 'async_trait>(
    &'life0 self,
    atime: Option<SystemTimeSpec>,
    mtime: Option<SystemTimeSpec>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

fn num_ready_bytes<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

fn readable<'life0, 'async_trait>(
    &'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

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

Auto Trait Implementations

impl<W> RefUnwindSafe for WritePipe<W>

impl<W> Send for WritePipe<W> where
    W: Send + Sync

impl<W> Sync for WritePipe<W> where
    W: Send + Sync

impl<W> Unpin for WritePipe<W>

impl<W> UnwindSafe for WritePipe<W>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

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

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

fn in_current_span(self) -> Instrumented<Self>[src]

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Pointee for T[src]

type Pointer = u32

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.

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

pub fn vzip(self) -> V