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

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

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 ctx = WasiCtx::builder(random, clocks, sched, table)
            .stdout(Box::new(stdout.clone()))
            .build();
// 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]

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

impl<W: Write + Any> WasiFile for WritePipe<W>[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]

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

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

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

impl<T> Instrument for T[src]

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

impl<T> Pointee for T[src]

type Pointer = u32

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

type Owned = T

The resulting type after obtaining ownership.

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.

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.

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