#[repr(transparent)]pub struct IoImpl<T>(pub T);
Expand description
A small newtype wrapper which serves as the basis for implementations of
Host
WASI traits in this crate.
This type is used as the basis for the implementation of all Host
traits
generated by bindgen!
for WASI interfaces.
You don’t need to use this type if you are using the root
add_to_linker_async
in this crate.
If you’re calling the add_to_linker
functions generated by bindgen!
from the bindings
module, you’ll want to create a
value of this type in the closures added to a Linker
.
Tuple Fields§
§0: T
Trait Implementations§
Source§impl<T> Host for IoImpl<T>where
T: IoView,
impl<T> Host for IoImpl<T>where
T: IoView,
fn convert_stream_error( &mut self, err: StreamError, ) -> Result<StreamError, Error>
Source§impl<T> Host for IoImpl<T>where
T: IoView,
impl<T> Host for IoImpl<T>where
T: IoView,
fn convert_stream_error(&mut self, err: StreamError) -> Result<StreamError>
Source§impl<T> HostInputStream for IoImpl<T>where
T: IoView,
impl<T> HostInputStream for IoImpl<T>where
T: IoView,
async fn drop( &mut self, stream: Resource<Box<dyn InputStream>>, ) -> Result<(), Error>
Source§fn read(
&mut self,
stream: Resource<Box<dyn InputStream>>,
len: u64,
) -> Result<Vec<u8>, StreamError>
fn read( &mut self, stream: Resource<Box<dyn InputStream>>, len: u64, ) -> Result<Vec<u8>, StreamError>
Perform a non-blocking read from the stream. Read more
Source§async fn blocking_read(
&mut self,
stream: Resource<Box<dyn InputStream>>,
len: u64,
) -> Result<Vec<u8>, StreamError>
async fn blocking_read( &mut self, stream: Resource<Box<dyn InputStream>>, len: u64, ) -> Result<Vec<u8>, StreamError>
Read bytes from a stream, after blocking until at least one byte can
be read. Except for blocking, behavior is identical to
read
.Source§fn skip(
&mut self,
stream: Resource<Box<dyn InputStream>>,
len: u64,
) -> Result<u64, StreamError>
fn skip( &mut self, stream: Resource<Box<dyn InputStream>>, len: u64, ) -> Result<u64, StreamError>
Skip bytes from a stream. Returns number of bytes skipped. Read more
Source§async fn blocking_skip(
&mut self,
stream: Resource<Box<dyn InputStream>>,
len: u64,
) -> Result<u64, StreamError>
async fn blocking_skip( &mut self, stream: Resource<Box<dyn InputStream>>, len: u64, ) -> Result<u64, StreamError>
Skip bytes from a stream, after blocking until at least one byte
can be skipped. Except for blocking behavior, identical to
skip
.Source§fn subscribe(
&mut self,
stream: Resource<Box<dyn InputStream>>,
) -> Result<Resource<DynPollable>, Error>
fn subscribe( &mut self, stream: Resource<Box<dyn InputStream>>, ) -> Result<Resource<DynPollable>, Error>
Create a
pollable
which will resolve once either the specified stream
has bytes available to read or the other end of the stream has been
closed.
The created pollable
is a child resource of the input-stream
.
Implementations may trap if the input-stream
is dropped before
all derived pollable
s created with this function are dropped.Source§impl<T> HostInputStream for IoImpl<T>where
T: IoView,
impl<T> HostInputStream for IoImpl<T>where
T: IoView,
fn drop(&mut self, stream: Resource<InputStream>) -> Result<()>
Source§fn read(
&mut self,
stream: Resource<InputStream>,
len: u64,
) -> StreamResult<Vec<u8>>
fn read( &mut self, stream: Resource<InputStream>, len: u64, ) -> StreamResult<Vec<u8>>
Perform a non-blocking read from the stream. Read more
Source§fn blocking_read(
&mut self,
stream: Resource<InputStream>,
len: u64,
) -> StreamResult<Vec<u8>>
fn blocking_read( &mut self, stream: Resource<InputStream>, len: u64, ) -> StreamResult<Vec<u8>>
Read bytes from a stream, after blocking until at least one byte can
be read. Except for blocking, behavior is identical to
read
.Source§fn skip(&mut self, stream: Resource<InputStream>, len: u64) -> StreamResult<u64>
fn skip(&mut self, stream: Resource<InputStream>, len: u64) -> StreamResult<u64>
Skip bytes from a stream. Returns number of bytes skipped. Read more
Source§fn blocking_skip(
&mut self,
stream: Resource<InputStream>,
len: u64,
) -> StreamResult<u64>
fn blocking_skip( &mut self, stream: Resource<InputStream>, len: u64, ) -> StreamResult<u64>
Skip bytes from a stream, after blocking until at least one byte
can be skipped. Except for blocking behavior, identical to
skip
.Source§fn subscribe(
&mut self,
stream: Resource<InputStream>,
) -> Result<Resource<Pollable>>
fn subscribe( &mut self, stream: Resource<InputStream>, ) -> Result<Resource<Pollable>>
Create a
pollable
which will resolve once either the specified stream
has bytes available to read or the other end of the stream has been
closed.
The created pollable
is a child resource of the input-stream
.
Implementations may trap if the input-stream
is dropped before
all derived pollable
s created with this function are dropped.Source§impl<T> HostOutputStream for IoImpl<T>where
T: IoView,
impl<T> HostOutputStream for IoImpl<T>where
T: IoView,
async fn drop( &mut self, stream: Resource<Box<dyn OutputStream>>, ) -> Result<(), Error>
Source§fn check_write(
&mut self,
stream: Resource<Box<dyn OutputStream>>,
) -> Result<u64, StreamError>
fn check_write( &mut self, stream: Resource<Box<dyn OutputStream>>, ) -> Result<u64, StreamError>
Check readiness for writing. This function never blocks. Read more
Source§fn write(
&mut self,
stream: Resource<Box<dyn OutputStream>>,
bytes: Vec<u8>,
) -> Result<(), StreamError>
fn write( &mut self, stream: Resource<Box<dyn OutputStream>>, bytes: Vec<u8>, ) -> Result<(), StreamError>
Perform a write. This function never blocks. Read more
Source§fn subscribe(
&mut self,
stream: Resource<Box<dyn OutputStream>>,
) -> Result<Resource<DynPollable>, Error>
fn subscribe( &mut self, stream: Resource<Box<dyn OutputStream>>, ) -> Result<Resource<DynPollable>, Error>
Create a
pollable
which will resolve once the output-stream
is ready for more writing, or an error has occurred. When this
pollable is ready, check-write
will return ok(n)
with n>0, or an
error. Read moreSource§async fn blocking_write_and_flush(
&mut self,
stream: Resource<Box<dyn OutputStream>>,
bytes: Vec<u8>,
) -> Result<(), StreamError>
async fn blocking_write_and_flush( &mut self, stream: Resource<Box<dyn OutputStream>>, bytes: Vec<u8>, ) -> Result<(), StreamError>
Perform a write of up to 4096 bytes, and then flush the stream. Block
until all of these operations are complete, or an error occurs. Read more
Source§async fn blocking_write_zeroes_and_flush(
&mut self,
stream: Resource<Box<dyn OutputStream>>,
len: u64,
) -> Result<(), StreamError>
async fn blocking_write_zeroes_and_flush( &mut self, stream: Resource<Box<dyn OutputStream>>, len: u64, ) -> Result<(), StreamError>
Perform a write of up to 4096 zeroes, and then flush the stream.
Block until all of these operations are complete, or an error
occurs. Read more
Source§fn write_zeroes(
&mut self,
stream: Resource<Box<dyn OutputStream>>,
len: u64,
) -> Result<(), StreamError>
fn write_zeroes( &mut self, stream: Resource<Box<dyn OutputStream>>, len: u64, ) -> Result<(), StreamError>
Write zeroes to a stream. Read more
Source§fn flush(
&mut self,
stream: Resource<Box<dyn OutputStream>>,
) -> Result<(), StreamError>
fn flush( &mut self, stream: Resource<Box<dyn OutputStream>>, ) -> Result<(), StreamError>
Request to flush buffered output. This function never blocks. Read more
Source§async fn blocking_flush(
&mut self,
stream: Resource<Box<dyn OutputStream>>,
) -> Result<(), StreamError>
async fn blocking_flush( &mut self, stream: Resource<Box<dyn OutputStream>>, ) -> Result<(), StreamError>
Request to flush buffered output, and block until flush completes
and stream is ready for writing again.
Source§fn splice(
&mut self,
dest: Resource<Box<dyn OutputStream>>,
src: Resource<Box<dyn InputStream>>,
len: u64,
) -> Result<u64, StreamError>
fn splice( &mut self, dest: Resource<Box<dyn OutputStream>>, src: Resource<Box<dyn InputStream>>, len: u64, ) -> Result<u64, StreamError>
Read from one stream and write to another. Read more
Source§async fn blocking_splice(
&mut self,
dest: Resource<Box<dyn OutputStream>>,
src: Resource<Box<dyn InputStream>>,
len: u64,
) -> Result<u64, StreamError>
async fn blocking_splice( &mut self, dest: Resource<Box<dyn OutputStream>>, src: Resource<Box<dyn InputStream>>, len: u64, ) -> Result<u64, StreamError>
Read from one stream and write to another, with blocking. Read more
Source§impl<T> HostOutputStream for IoImpl<T>where
T: IoView,
impl<T> HostOutputStream for IoImpl<T>where
T: IoView,
fn drop(&mut self, stream: Resource<OutputStream>) -> Result<()>
Source§fn check_write(&mut self, stream: Resource<OutputStream>) -> StreamResult<u64>
fn check_write(&mut self, stream: Resource<OutputStream>) -> StreamResult<u64>
Check readiness for writing. This function never blocks. Read more
Source§fn write(
&mut self,
stream: Resource<OutputStream>,
bytes: Vec<u8>,
) -> StreamResult<()>
fn write( &mut self, stream: Resource<OutputStream>, bytes: Vec<u8>, ) -> StreamResult<()>
Perform a write. This function never blocks. Read more
Source§fn blocking_write_and_flush(
&mut self,
stream: Resource<OutputStream>,
bytes: Vec<u8>,
) -> StreamResult<()>
fn blocking_write_and_flush( &mut self, stream: Resource<OutputStream>, bytes: Vec<u8>, ) -> StreamResult<()>
Perform a write of up to 4096 bytes, and then flush the stream. Block
until all of these operations are complete, or an error occurs. Read more
Source§fn blocking_write_zeroes_and_flush(
&mut self,
stream: Resource<OutputStream>,
len: u64,
) -> StreamResult<()>
fn blocking_write_zeroes_and_flush( &mut self, stream: Resource<OutputStream>, len: u64, ) -> StreamResult<()>
Perform a write of up to 4096 zeroes, and then flush the stream.
Block until all of these operations are complete, or an error
occurs. Read more
Source§fn subscribe(
&mut self,
stream: Resource<OutputStream>,
) -> Result<Resource<Pollable>>
fn subscribe( &mut self, stream: Resource<OutputStream>, ) -> Result<Resource<Pollable>>
Create a
pollable
which will resolve once the output-stream
is ready for more writing, or an error has occurred. When this
pollable is ready, check-write
will return ok(n)
with n>0, or an
error. Read moreSource§fn write_zeroes(
&mut self,
stream: Resource<OutputStream>,
len: u64,
) -> StreamResult<()>
fn write_zeroes( &mut self, stream: Resource<OutputStream>, len: u64, ) -> StreamResult<()>
Write zeroes to a stream. Read more
Source§fn flush(&mut self, stream: Resource<OutputStream>) -> StreamResult<()>
fn flush(&mut self, stream: Resource<OutputStream>) -> StreamResult<()>
Request to flush buffered output. This function never blocks. Read more
Source§fn blocking_flush(&mut self, stream: Resource<OutputStream>) -> StreamResult<()>
fn blocking_flush(&mut self, stream: Resource<OutputStream>) -> StreamResult<()>
Request to flush buffered output, and block until flush completes
and stream is ready for writing again.
Source§fn splice(
&mut self,
dst: Resource<OutputStream>,
src: Resource<InputStream>,
len: u64,
) -> StreamResult<u64>
fn splice( &mut self, dst: Resource<OutputStream>, src: Resource<InputStream>, len: u64, ) -> StreamResult<u64>
Read from one stream and write to another. Read more
Source§fn blocking_splice(
&mut self,
dst: Resource<OutputStream>,
src: Resource<InputStream>,
len: u64,
) -> StreamResult<u64>
fn blocking_splice( &mut self, dst: Resource<OutputStream>, src: Resource<InputStream>, len: u64, ) -> StreamResult<u64>
Read from one stream and write to another, with blocking. Read more
Source§impl<T> HostPollable for IoImpl<T>where
T: IoView,
impl<T> HostPollable for IoImpl<T>where
T: IoView,
Source§async fn block(&mut self, pollable: Resource<DynPollable>) -> Result<(), Error>
async fn block(&mut self, pollable: Resource<DynPollable>) -> Result<(), Error>
block
returns immediately if the pollable is ready, and otherwise
blocks until ready. Read moreSource§async fn ready(
&mut self,
pollable: Resource<DynPollable>,
) -> Result<bool, Error>
async fn ready( &mut self, pollable: Resource<DynPollable>, ) -> Result<bool, Error>
Return the readiness of a pollable. This function never blocks. Read more
fn drop(&mut self, pollable: Resource<DynPollable>) -> Result<(), Error>
Source§impl<T> HostPollable for IoImpl<T>where
T: IoView,
impl<T> HostPollable for IoImpl<T>where
T: IoView,
Source§fn ready(&mut self, pollable: Resource<DynPollable>) -> Result<bool>
fn ready(&mut self, pollable: Resource<DynPollable>) -> Result<bool>
Return the readiness of a pollable. This function never blocks. Read more
Source§fn block(&mut self, pollable: Resource<DynPollable>) -> Result<()>
fn block(&mut self, pollable: Resource<DynPollable>) -> Result<()>
block
returns immediately if the pollable is ready, and otherwise
blocks until ready. Read morefn drop(&mut self, pollable: Resource<DynPollable>) -> Result<()>
impl<T> Host for IoImpl<T>where
T: IoView,
Auto Trait Implementations§
impl<T> Freeze for IoImpl<T>where
T: Freeze,
impl<T> RefUnwindSafe for IoImpl<T>where
T: RefUnwindSafe,
impl<T> Send for IoImpl<T>where
T: Send,
impl<T> Sync for IoImpl<T>where
T: Sync,
impl<T> Unpin for IoImpl<T>where
T: Unpin,
impl<T> UnwindSafe for IoImpl<T>where
T: UnwindSafe,
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
§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
§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.§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§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more