pub struct Lines<OutgoingSink, IncomingStream> { /* private fields */ }Expand description
A component that communicates over line streams.
Lines implements the ConnectTo trait for any pair of line-based streams
(a Stream<Item = io::Result<String>> for incoming and a Sink<String> for outgoing),
handling serialization of JSON-RPC messages to/from newline-delimited JSON.
Each line carries one JSON-RPC message. JSON-RPC batch arrays are not supported: an
incoming array is answered with a single invalid-request (-32600) error with id: null.
This is a lower-level primitive than ByteStreams that enables interception and
transformation of individual lines before they are parsed or after they are serialized.
This is particularly useful for debugging, logging, or implementing custom line-based
protocols.
§Use Cases
- Line-by-line logging: Intercept and log each line before parsing
- Custom protocols: Transform lines before/after JSON-RPC processing
- Debugging: Inspect raw message strings
- Line filtering: Skip or modify specific messages
Most users should use ByteStreams instead, which provides a simpler interface
for byte-based I/O.