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 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]
impl<W: Write> WritePipe<W>
[src]pub fn new(w: W) -> Self
[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]
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]
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]
impl WritePipe<Cursor<Vec<u8>>>
[src]pub fn new_in_memory() -> Self
[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 + Any> WasiFile for WritePipe<W>
[src]
impl<W: Write + Any> WasiFile for WritePipe<W>
[src]fn as_any(&self) -> &dyn Any
[src]
fn datasync(&self) -> Result<(), Error>
[src]
fn sync(&self) -> Result<(), Error>
[src]
fn get_filetype(&self) -> Result<FileType, Error>
[src]
fn get_fdflags(&self) -> Result<FdFlags, Error>
[src]
fn set_fdflags(&mut self, _fdflags: FdFlags) -> Result<(), Error>
[src]
fn get_filestat(&self) -> Result<Filestat, Error>
[src]
fn set_filestat_size(&self, _size: u64) -> Result<(), Error>
[src]
fn advise(&self, offset: u64, len: u64, advice: Advice) -> Result<(), Error>
[src]
fn allocate(&self, offset: u64, len: u64) -> Result<(), Error>
[src]
fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> Result<u64, Error>
[src]
fn read_vectored_at(
&self,
bufs: &mut [IoSliceMut<'_>],
offset: u64
) -> Result<u64, Error>
[src]
&self,
bufs: &mut [IoSliceMut<'_>],
offset: u64
) -> Result<u64, Error>
fn write_vectored(&self, bufs: &[IoSlice<'_>]) -> Result<u64, Error>
[src]
fn write_vectored_at(
&self,
bufs: &[IoSlice<'_>],
offset: u64
) -> Result<u64, Error>
[src]
&self,
bufs: &[IoSlice<'_>],
offset: u64
) -> Result<u64, Error>
fn seek(&self, pos: SeekFrom) -> Result<u64, Error>
[src]
fn peek(&self, buf: &mut [u8]) -> Result<u64, Error>
[src]
fn set_times(
&self,
atime: Option<SystemTimeSpec>,
mtime: Option<SystemTimeSpec>
) -> Result<(), Error>
[src]
&self,
atime: Option<SystemTimeSpec>,
mtime: Option<SystemTimeSpec>
) -> Result<(), Error>
fn num_ready_bytes(&self) -> Result<u64, Error>
[src]
Auto Trait Implementations
impl<W> RefUnwindSafe for WritePipe<W>
impl<W> Send for WritePipe<W> where
W: Send + Sync,
W: Send + Sync,
impl<W> Sync for WritePipe<W> where
W: Send + Sync,
W: Send + Sync,
impl<W> Unpin for WritePipe<W>
impl<W> UnwindSafe for WritePipe<W>
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[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]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
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]
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<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,