Skip to main content

DecodedLine

Enum DecodedLine 

Source
pub enum DecodedLine {
    Message(Box<Message>),
    Control(Box<ControlRequest>),
    ControlCancel {
        request_id: String,
    },
    ControlResponse {
        request_id: String,
        raw: Value,
    },
    Unknown {
        type_str: String,
        raw: Value,
    },
    Malformed {
        line: u64,
        reason: String,
    },
}
Expand description

A single stream-json line from the subprocess - either a regular message or a control request.

Variants§

§

Message(Box<Message>)

An assistant/user/system/result message.

Boxed: a Message is 536 bytes and every other variant here is a fraction of that (clippy::large_enum_variant). The value is decoded once per line and moved straight into the reader, so the indirection costs one allocation and saves the enum being 536 bytes wherever a line is passed around.

§

Control(Box<ControlRequest>)

A control request (e.g. permission check, MCP message, hook callback).

Boxed for the same reason as Self::Message: it is 312 bytes of its own and is dispatched once and dropped.

§

ControlCancel

The CLI has withdrawn a previously-issued control_request - the handler matching request_id should be cancelled if still in flight. Wire shape {"type":"control_cancel_request","request_id":"..."} .

Fields

§request_id: String

request_id of the control_request being withdrawn.

§

ControlResponse

The CLI is responding to an outbound control_request we sent (initialize, interrupt, set_permission_mode, …). These arrive on stdout and are normally consumed synchronously by the client’s outbound-control wait loop - the read-dispatch loop in the events stream returned by Client::spawn never sees them. Represented here so downstream tools (the wire-conformance replay harness, debug captures) can recognise and categorise the frame instead of mis-flagging it as Unknown.

Fields

§request_id: String

request_id of the outbound control_request this responds to.

§raw: Value

Full JSON payload - useful for inspection and replay.

§

Unknown

Forward-compat fallback: the CLI emitted a frame with an unrecognised top-level type field. Forge-sdk doesn’t crash on these - it logs a warning via tracing::warn! in the dispatch path and lets the reader continue. Callers (like the wire-conformance harness) can detect and report these explicitly by matching this variant.

type_str is the raw type field value the CLI sent; raw is the full JSON object for inspection / logging / replay. Neither is typed - by definition, we don’t know what this frame is.

Fields

§type_str: String

The unrecognised type field value.

§raw: Value

Full JSON payload for later inspection.

§

Malformed

A line that failed to decode: not valid JSON, or valid JSON that matched no message shape. Typed rather than an Err so the read loop skips the line and continues - a per-line decode failure must not end the session, the same rule Unknown applies to unknown types. The reader warns with the line number, reason and a 160-char excerpt, and answers a corrupt control_request that carries a request_id.

Fields

§line: u64

1-based number of the offending line.

§reason: String

Why the line failed to decode.

Trait Implementations§

Source§

impl Clone for DecodedLine

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DecodedLine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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