Crate rotor_stream [−] [src]
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.
Modules
sync |
Provides state machine that is guarded by Mutex |
Structs
Buf |
A buffer object to be used for reading from network |
Intent |
A structure that encapsulates a state machine and an expectation |
IntentBuilder |
A helper class returned from |
Persistent |
Persistent client connection |
ProtocolStop |
Protocol returned None right at the start of the stream processing |
Stream |
A main stream state machine abstaction |
Transport |
Transport is thing that provides buffered I/O for stream sockets |
Enums
Accept |
Socket acceptor State Machine |
Exception |
An exception value that is received in |
Expectation |
This is an enumeration used to declare what next protocol is expecting |
Constants
MAX_BUF_SIZE |
Maximum size of buffer allowed. Note: we assert on this size. Most network servers should set their own limits to something much smaller. |
Traits
Accepted |
Trait which must be implemented for a state machine to accept connection |
ActiveStream | |
Protocol | |
SocketError | |
StreamSocket |