Struct wasmtime_wasi::preview2::pipe::WritePipe
source · pub struct WritePipe<W: Write> { /* private fields */ }
Expand description
A virtual pipe write end.
use wasmtime_wasi::preview2::{pipe::WritePipe, WasiCtxBuilder, Table};
let mut table = Table::new();
let stdout = WritePipe::new_in_memory();
let mut ctx = WasiCtxBuilder::new().set_stdout(stdout.clone()).build(&mut table).unwrap();
// use ctx and table in an instance, then make sure it is dropped:
drop(ctx);
drop(table);
let contents: Vec<u8> = stdout.try_into_inner().expect("sole remaining reference to WritePipe").into_inner();
println!("contents of stdout: {:?}", contents);
Implementations§
source§impl<W: Write> WritePipe<W>
impl<W: Write> WritePipe<W>
sourcepub fn new(w: W) -> Self
pub fn new(w: W) -> Self
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.
sourcepub fn try_into_inner(self) -> Result<W, Self>
pub fn try_into_inner(self) -> Result<W, Self>
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.
Trait Implementations§
source§impl<W: Write + Any + Send + Sync> OutputStream for WritePipe<W>
impl<W: Write + Any + Send + Sync> OutputStream for WritePipe<W>
fn as_any(&self) -> &dyn Any
source§fn write<'life0, 'life1, 'async_trait>(
&'life0 mut self,
buf: &'life1 [u8]
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn write<'life0, 'life1, 'async_trait>( &'life0 mut self, buf: &'life1 [u8] ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Write bytes. On success, returns the number of bytes written.
source§fn write_zeroes<'life0, 'async_trait>(
&'life0 mut self,
nelem: u64
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn write_zeroes<'life0, 'async_trait>( &'life0 mut self, nelem: u64 ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Repeatedly write a byte to a stream.
source§fn writable<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn writable<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Test whether this stream is writable.
source§fn pollable_write(&self) -> Option<BorrowedFd<'_>>
fn pollable_write(&self) -> Option<BorrowedFd<'_>>
If this stream is writing from a host file descriptor, return it so
that it can be polled with a host poll.
source§fn write_vectored<'a, 'life0, 'life1, 'async_trait>(
&'life0 mut self,
_bufs: &'life1 [IoSlice<'a>]
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn write_vectored<'a, 'life0, 'life1, 'async_trait>( &'life0 mut self, _bufs: &'life1 [IoSlice<'a>] ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Vectored-I/O form of
write
.source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
Test whether vectored I/O writes are known to be optimized in the
underlying implementation.
source§fn splice<'life0, 'life1, 'async_trait>(
&'life0 mut self,
src: &'life1 mut dyn InputStream,
nelem: u64
) -> Pin<Box<dyn Future<Output = Result<(u64, bool), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn splice<'life0, 'life1, 'async_trait>( &'life0 mut self, src: &'life1 mut dyn InputStream, nelem: u64 ) -> Pin<Box<dyn Future<Output = Result<(u64, bool), Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Transfer bytes directly from an input stream to an output stream.
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where T: AsFilelike,
Query the “status” flags for the
self
file descriptor.source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where T: AsFilelike,
source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where T: AsFilelike,
Set the “status” flags for the
self
file descriptor. Read more