[−][src]Trait ffsend_api::pipe::prelude::Pipe
Something that can pipe given data.
A pipe may monitor, but also transform data flowing through it.
From this pipe, a reader or writer can be created using the corresponding reader
and writer
functions to wrap an existing reader or writer.
Associated Types
type Reader: PipeRead<Self>
The wrapping reader type used for this pipe.
type Writer: PipeWrite<Self>
The wrapping writer type used for this pipe.
Required methods
fn pipe(&mut self, input: &[u8]) -> (usize, Option<Vec<u8>>)
Pipe bytes from input
, monitor/transform it, return the output.
This should not be used directly, and is automatically used by a PipeRead
or PipeWrite
object for the actual piping.
This returns a tuple with the number of bytes read from the input
, along with transformed
data if available in the following format: (read_bytes, transformed_data)
.
Pipes that just monitor data, immediately return the input.
The pipe_transparent
helper function can be used for this inside the implementation.
Provided methods
fn reader(self, inner: Box<dyn Read>) -> Self::Reader
Wrap the inner
reader, bytes that are read are transformed through this pipe.
fn writer(self, inner: Box<dyn Write>) -> Self::Writer
Wrap the inner
writer, bytes that are read are transformed through this pipe.
fn pipe_transparent(&self, input: &[u8]) -> (usize, Option<Vec<u8>>)
Transparently pipe input
by immediately returning it.
This should not be used directly, and is automatically used by a PipeRead
or PipeWrite
object for the actual piping.
This can be used as helper function inside the pipe
function if data is only monitored
and not transformed.