Struct wasi_common::pipe::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>
impl<R: Read> ReadPipe<R>
sourcepub fn new(r: R) -> Self
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.
Create a new pipe from a shareable Read
type.
All Handle
read operations delegate to reading from this underlying reader.
sourcepub fn try_into_inner(self) -> Result<R, Self>
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.