Crate mockpipe

Source
Expand description

Provides the MockPipe struct for exchanging data through internal circular buffers. It supports reading and writing with optional timeout functionality and is useful for testing communication mechanisms like sockets, pipes, serial ports etc.

§Example

use std::io::{Read, Write};

use mockpipe::MockPipe;

let mut pipe = MockPipe::loopback(1024);

let write_data = b"hello";
pipe.write_all(write_data).unwrap();

let mut read_data = [0u8; 5];
pipe.read_exact(&mut read_data).unwrap();

assert_eq!(&read_data, write_data);

Structs§

MockPipe
A bidirectional data pipe that exchanges datausing internal circular buffers. It provides functionality for reading and writing data with timeout support. Can be used in loopback mode or as a paired connection between two endpoints.