pub trait Tube {
fn get_buffer(&mut self) -> &mut Buffer;
fn fill_buffer(&mut self, timeout: Option<Duration>) -> Result<usize>;
fn close(&mut self) -> Result<()>;
fn clean(&mut self, timeout: Duration) -> Result<Vec<u8>> { ... }
fn recv(&mut self) -> Result<Vec<u8>> { ... }
fn recvn(&mut self, n: usize) -> Result<Vec<u8>> { ... }
fn recvrepeat(&mut self, timeout: Option<Duration>) -> Result<Vec<u8>> { ... }
fn send<T: Into<Vec<u8>>>(&mut self, data: T) -> Result<()> { ... }
fn sendline<T: Into<Vec<u8>>>(&mut self, data: T) -> Result<()> { ... }
fn recvuntil(&mut self, delim: &[u8]) -> Result<Vec<u8>> { ... }
fn recvline(&mut self) -> Result<Vec<u8>> { ... }
fn interactive(&mut self) -> Result<()>
where
Self: Clone + Send,
{ ... }
}
Expand description
Generic Tube
trait, used as the underlying interface for IO.
Required methods
fn get_buffer(&mut self) -> &mut Buffer
fn get_buffer(&mut self) -> &mut Buffer
Retrieve mutable reference to the internal Buffer
.
Fill the internal Buffer
.
timeout
- Maximum time to fill for. IfNone
, block until data is read.
Provided methods
Retrieve all data from the Tube
.
timeout
- The maximum time to read for, defaults to 0.05s. If 0, clean only the internal buffer.
Receives from the Tube
, returning once any data is available.
Receive all data from the Tube
, repeatedly reading with the given timeout
.
Appends a newline to the data before writing it to the Tube
.
Receive until the given delimiter is received.