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.
An incoming line may contain one JSON-RPC message or a non-empty batch array. Batch
entries are dispatched individually in source order, and responses to the batch are
collected into one response-array line. SDK-initiated requests and notifications remain
individual messages.
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.