6 releases (3 breaking)
Uses old Rust 2015
0.6.2 | Mar 30, 2016 |
---|---|
0.6.1 | Mar 28, 2016 |
0.5.1 | Mar 3, 2016 |
0.4.0 | Feb 10, 2016 |
0.1.0 |
|
#9 in #rotor
87 downloads per month
Used in 4 crates
47KB
973 lines
Rotor Stream
Status: | Alpha |
---|---|
Dependencies: | rotor, mio, netbuf |
A stream abstraction based on MIO. Features:
- State machine-based implementation (as usually in rotor)
- Uses netbuf for buffering, buffer has contiguous data slice (easy parsing)
- Input data abstractions: read-x-bytes, read-until-delimiter
- Perfect for request-reply style protocols
- Independent of whether it's client or server, tcp or unix sockets
- (TODO) should work on top of SSL later
lib.rs
:
Stream abstraction for rotor
The crate provides:
- Buffering for network sockets
- Simple abstractions like read N bytes, read until '\n'
- Persistent (auto-reconnecting) client connections
- Abstraction for accepting connection on server-side
Assumptions for streams:
- You read data by length-prefixed or fixed-string-delimited chunks rather than byte-by-byte
- Each chunk fits memory
- Your data stream is not entirely full-duplex: while you can read and write simultaneously, when you apply pushback (i.e. waiting for bytes to be flushed), you can't do reads [*]
[*] This matches HTTP perfectly, and most bidirectional interactive workflows (including based on websockets). But for some cases may be hard to implement. One such case is when you need to generate some output stream (you can't buffer it), and have to parse input stream at the same time.
Dependencies
~4.5MB
~83K SLoC