Crate rotor_stream

Source
Expand description

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:

  1. You read data by length-prefixed or fixed-string-delimited chunks rather than byte-by-byte
  2. Each chunk fits memory
  3. 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.

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 Intent::of()
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 Protocol::exception method
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