Rust library to manage streams in a I/O-agnostic way.
This library does not perform I/O the usual way. It relies instead on 3 concepts:
The flow is an I/O-free, composable and iterable state machine that emits I/O requests. A flow is considered terminated when it does not emit I/O requests anymore.
The I/O handler processes I/O requests. It gathers all the I/O logic. It takes input from the flow, performs I/O, then puts the output back inside the flow.
See available handlers at ./handlers.
The loop is the glue between the flow and the I/O handler. It makes the flow progress and the I/O being processed.
See complete examples at ./examples.
You can also have a look at projects based on stream flows:
use stream_flows::State;
use stream_std::Handler as StreamStdHandler;
let mut stdin = std::io::stdin();
let mut state = State::default();
let n = StreamStdHandler::read(&mut tcp, &mut state).unwrap();
let input = String::from_utf8_lossy(state.get_read_bytes(n));
use stream_flows::State;
use stream_std::Handler as StreamStdHandler;
let mut tcp = std::net::TcpStream::connect("127.0.0.1:1234").unwrap();
let mut state = State::default();
state.enqueue_bytes(b"data");
StreamStdHandler::write(&mut tcp, &mut state).unwrap();
Special thanks to the NLnet foundation and the European Commission that helped the project to receive financial support from various programs:
- NGI Assure in 2022
- NGI Zero Entrust in 2023
- NGI Zero Core in 2024 (still ongoing)
If you appreciate the project, feel free to donate using one of the following providers: