Lines

Struct Lines 

Source
pub struct Lines<OutgoingSink, IncomingStream> {
    pub outgoing: OutgoingSink,
    pub incoming: IncomingStream,
}
Expand description

A component that communicates over line streams.

Lines implements the Component 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.

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.

Fields§

§outgoing: OutgoingSink

Outgoing line sink (where we write serialized JSON-RPC messages)

§incoming: IncomingStream

Incoming line stream (where we read and parse JSON-RPC messages)

Implementations§

Source§

impl<OutgoingSink, IncomingStream> Lines<OutgoingSink, IncomingStream>
where OutgoingSink: Sink<String, Error = Error> + Send + 'static, IncomingStream: Stream<Item = Result<String>> + Send + 'static,

Source

pub fn new(outgoing: OutgoingSink, incoming: IncomingStream) -> Self

Create a new line stream transport.

Trait Implementations§

Source§

impl<OutgoingSink, IncomingStream> Component for Lines<OutgoingSink, IncomingStream>
where OutgoingSink: Sink<String, Error = Error> + Send + 'static, IncomingStream: Stream<Item = Result<String>> + Send + 'static,

Source§

async fn serve(self, client: impl Component) -> Result<(), Error>

Serve this component by forwarding to a client component. Read more
Source§

fn into_server(self) -> (Channel, BoxFuture<'static, Result<(), Error>>)

Convert this component into a channel endpoint and server future. Read more

Auto Trait Implementations§

§

impl<OutgoingSink, IncomingStream> Freeze for Lines<OutgoingSink, IncomingStream>
where OutgoingSink: Freeze, IncomingStream: Freeze,

§

impl<OutgoingSink, IncomingStream> RefUnwindSafe for Lines<OutgoingSink, IncomingStream>
where OutgoingSink: RefUnwindSafe, IncomingStream: RefUnwindSafe,

§

impl<OutgoingSink, IncomingStream> Send for Lines<OutgoingSink, IncomingStream>
where OutgoingSink: Send, IncomingStream: Send,

§

impl<OutgoingSink, IncomingStream> Sync for Lines<OutgoingSink, IncomingStream>
where OutgoingSink: Sync, IncomingStream: Sync,

§

impl<OutgoingSink, IncomingStream> Unpin for Lines<OutgoingSink, IncomingStream>
where OutgoingSink: Unpin, IncomingStream: Unpin,

§

impl<OutgoingSink, IncomingStream> UnwindSafe for Lines<OutgoingSink, IncomingStream>
where OutgoingSink: UnwindSafe, IncomingStream: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more