pub trait Host {
Show 15 methods
// Required methods
fn read<'life0, 'async_trait>(
&'life0 mut self,
this: InputStream,
len: u64
) -> Pin<Box<dyn Future<Output = Result<(Vec<u8>, StreamStatus), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn blocking_read<'life0, 'async_trait>(
&'life0 mut self,
this: InputStream,
len: u64
) -> Pin<Box<dyn Future<Output = Result<(Vec<u8>, StreamStatus), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn skip<'life0, 'async_trait>(
&'life0 mut self,
this: InputStream,
len: u64
) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn blocking_skip<'life0, 'async_trait>(
&'life0 mut self,
this: InputStream,
len: u64
) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn subscribe_to_input_stream<'life0, 'async_trait>(
&'life0 mut self,
this: InputStream
) -> Pin<Box<dyn Future<Output = Result<Pollable>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn drop_input_stream<'life0, 'async_trait>(
&'life0 mut self,
this: InputStream
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn write<'life0, 'async_trait>(
&'life0 mut self,
this: OutputStream,
buf: Vec<u8>
) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn blocking_write<'life0, 'async_trait>(
&'life0 mut self,
this: OutputStream,
buf: Vec<u8>
) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn write_zeroes<'life0, 'async_trait>(
&'life0 mut self,
this: OutputStream,
len: u64
) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn blocking_write_zeroes<'life0, 'async_trait>(
&'life0 mut self,
this: OutputStream,
len: u64
) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn splice<'life0, 'async_trait>(
&'life0 mut self,
this: OutputStream,
src: InputStream,
len: u64
) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn blocking_splice<'life0, 'async_trait>(
&'life0 mut self,
this: OutputStream,
src: InputStream,
len: u64
) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn forward<'life0, 'async_trait>(
&'life0 mut self,
this: OutputStream,
src: InputStream
) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn subscribe_to_output_stream<'life0, 'async_trait>(
&'life0 mut self,
this: OutputStream
) -> Pin<Box<dyn Future<Output = Result<Pollable>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn drop_output_stream<'life0, 'async_trait>(
&'life0 mut self,
this: OutputStream
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}
Required Methods§
sourcefn read<'life0, 'async_trait>(
&'life0 mut self,
this: InputStream,
len: u64
) -> Pin<Box<dyn Future<Output = Result<(Vec<u8>, StreamStatus), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn read<'life0, 'async_trait>( &'life0 mut self, this: InputStream, len: u64 ) -> Pin<Box<dyn Future<Output = Result<(Vec<u8>, StreamStatus), Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Perform a non-blocking read from the stream.
This function returns a list of bytes containing the data that was
read, along with a stream-status
which, indicates whether further
reads are expected to produce data. The returned list will contain up to
len
bytes; it may return fewer than requested, but not more.
Once a stream has reached the end, subsequent calls to read or
skip
will always report end-of-stream rather than producing more
data.
If len
is 0, it represents a request to read 0 bytes, which should
always succeed, assuming the stream hasn’t reached its end yet, and
return an empty list.
The len here is a u64
, but some callees may not be able to allocate
a buffer as large as that would imply.
FIXME: describe what happens if allocation fails.
When the returned stream-status
is open
, the length of the returned
value may be less than len
. When an empty list is returned, this
indicates that no more bytes were available from the stream at that
time. In that case the subscribe-to-input-stream pollable will indicate
when additional bytes are available for reading.
sourcefn blocking_read<'life0, 'async_trait>(
&'life0 mut self,
this: InputStream,
len: u64
) -> Pin<Box<dyn Future<Output = Result<(Vec<u8>, StreamStatus), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn blocking_read<'life0, 'async_trait>( &'life0 mut self, this: InputStream, len: u64 ) -> Pin<Box<dyn Future<Output = Result<(Vec<u8>, StreamStatus), Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Read bytes from a stream, with blocking.
This is similar to read
, except that it blocks until at least one
byte can be read.
sourcefn skip<'life0, 'async_trait>(
&'life0 mut self,
this: InputStream,
len: u64
) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn skip<'life0, 'async_trait>( &'life0 mut self, this: InputStream, len: u64 ) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Skip bytes from a stream.
This is similar to the read
function, but avoids copying the
bytes into the instance.
Once a stream has reached the end, subsequent calls to read or
skip
will always report end-of-stream rather than producing more
data.
This function returns the number of bytes skipped, along with a bool
indicating whether the end of the stream was reached. The returned
value will be at most len
; it may be less.
sourcefn blocking_skip<'life0, 'async_trait>(
&'life0 mut self,
this: InputStream,
len: u64
) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn blocking_skip<'life0, 'async_trait>( &'life0 mut self, this: InputStream, len: u64 ) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Skip bytes from a stream, with blocking.
This is similar to skip
, except that it blocks until at least one
byte can be consumed.
sourcefn subscribe_to_input_stream<'life0, 'async_trait>(
&'life0 mut self,
this: InputStream
) -> Pin<Box<dyn Future<Output = Result<Pollable>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn subscribe_to_input_stream<'life0, 'async_trait>( &'life0 mut self, this: InputStream ) -> Pin<Box<dyn Future<Output = Result<Pollable>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
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.
sourcefn drop_input_stream<'life0, 'async_trait>(
&'life0 mut self,
this: InputStream
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn drop_input_stream<'life0, 'async_trait>( &'life0 mut self, this: InputStream ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Dispose of the specified input-stream
, after which it may no longer
be used.
sourcefn write<'life0, 'async_trait>(
&'life0 mut self,
this: OutputStream,
buf: Vec<u8>
) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn write<'life0, 'async_trait>( &'life0 mut self, this: OutputStream, buf: Vec<u8> ) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Perform a non-blocking write of bytes to a stream.
This function returns a u64
and a stream-status
. The u64
indicates
the number of bytes from buf
that were written, which may be less than
the length of buf
. The stream-status
indicates if further writes to
the stream are expected to be read.
When the returned stream-status
is open
, the u64
return value may
be less than the length of buf
. This indicates that no more bytes may
be written to the stream promptly. In that case the
subscribe-to-output-stream pollable will indicate when additional bytes
may be promptly written.
TODO: document what happens when an empty list is written
sourcefn blocking_write<'life0, 'async_trait>(
&'life0 mut self,
this: OutputStream,
buf: Vec<u8>
) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn blocking_write<'life0, 'async_trait>( &'life0 mut self, this: OutputStream, buf: Vec<u8> ) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Write bytes to a stream, with blocking.
This is similar to write
, except that it blocks until at least one
byte can be written.
sourcefn write_zeroes<'life0, 'async_trait>(
&'life0 mut self,
this: OutputStream,
len: u64
) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn write_zeroes<'life0, 'async_trait>( &'life0 mut self, this: OutputStream, len: u64 ) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Write multiple zero bytes to a stream.
This function returns a u64
indicating the number of zero bytes
that were written; it may be less than len
.
sourcefn blocking_write_zeroes<'life0, 'async_trait>(
&'life0 mut self,
this: OutputStream,
len: u64
) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn blocking_write_zeroes<'life0, 'async_trait>( &'life0 mut self, this: OutputStream, len: u64 ) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Write multiple zero bytes to a stream, with blocking.
This is similar to write-zeroes
, except that it blocks until at least
one byte can be written.
sourcefn splice<'life0, 'async_trait>(
&'life0 mut self,
this: OutputStream,
src: InputStream,
len: u64
) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn splice<'life0, 'async_trait>( &'life0 mut self, this: OutputStream, src: InputStream, len: u64 ) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Read from one stream and write to another.
This function returns the number of bytes transferred; it may be less
than len
.
Unlike other I/O functions, this function blocks until all the data read from the input stream has been written to the output stream.
sourcefn blocking_splice<'life0, 'async_trait>(
&'life0 mut self,
this: OutputStream,
src: InputStream,
len: u64
) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn blocking_splice<'life0, 'async_trait>( &'life0 mut self, this: OutputStream, src: InputStream, len: u64 ) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Read from one stream and write to another, with blocking.
This is similar to splice
, except that it blocks until at least
one byte can be read.
sourcefn forward<'life0, 'async_trait>(
&'life0 mut self,
this: OutputStream,
src: InputStream
) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn forward<'life0, 'async_trait>( &'life0 mut self, this: OutputStream, src: InputStream ) -> Pin<Box<dyn Future<Output = Result<(u64, StreamStatus), Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Forward the entire contents of an input stream to an output stream.
This function repeatedly reads from the input stream and writes the data to the output stream, until the end of the input stream is reached, or an error is encountered.
Unlike other I/O functions, this function blocks until the end of the input stream is seen and all the data has been written to the output stream.
This function returns the number of bytes transferred, and the status of the output stream.
sourcefn subscribe_to_output_stream<'life0, 'async_trait>(
&'life0 mut self,
this: OutputStream
) -> Pin<Box<dyn Future<Output = Result<Pollable>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn subscribe_to_output_stream<'life0, 'async_trait>( &'life0 mut self, this: OutputStream ) -> Pin<Box<dyn Future<Output = Result<Pollable>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Create a pollable
which will resolve once either the specified stream
is ready to accept bytes or the other end of the stream has been closed.
sourcefn drop_output_stream<'life0, 'async_trait>(
&'life0 mut self,
this: OutputStream
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn drop_output_stream<'life0, 'async_trait>( &'life0 mut self, this: OutputStream ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Dispose of the specified output-stream
, after which it may no longer
be used.