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

Retrieve mutable reference to the internal Buffer.

Fill the internal Buffer.

  • timeout - Maximum time to fill for. If None, block until data is read.

Close both ends of the Tube.

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.

Receives n bytes from the Tube.

Receive all data from the Tube, repeatedly reading with the given timeout.

Writes data to the Tube.

Appends a newline to the data before writing it to the Tube.

Receive until the given delimiter is received.

Receive from the tube until a newline is received.

Get an interactive prompt for the connection. A second thread will print messages as they arrive.

Implementors