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 = 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

Create a new pipe from a Write type.

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

Create a new pipe from a shareable Write type.

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

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.

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

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

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

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

Performs the conversion.

The resulting type after obtaining ownership.

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

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

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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

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