Skip to main content

Envelope

Enum Envelope 

Source
pub enum Envelope {
    Handshake {
        protocol_version: String,
    },
    HandshakeAck {
        protocol_version: String,
        provider: ProviderInfo,
        capabilities: Capabilities,
    },
    Query {
        id: Option<String>,
        query: ContextQuery,
    },
    Frames {
        id: Option<String>,
        result: ContextQueryResult,
    },
    Verify {
        request: VerifyRequest,
    },
    Verified {
        response: VerifyResponse,
    },
    Shutdown,
    Error {
        id: Option<String>,
        code: Option<ErrorCode>,
        message: String,
    },
}
Expand description

One Context Graph Protocol message. Every variant is a small, versioned, type-tagged JSON object; the host writes exactly one per line (NDJSON) over stdio and one per HTTP body (SPEC.md §2).

Variants§

§

Handshake

Host hello: opens the exchange with the protocol version the host speaks (SPEC.md §3 initialize).

Fields

§protocol_version: String
§

HandshakeAck

Provider hello-back: its protocol version, identity + declared data-flow direction, and negotiated capabilities (SPEC.md §3). The host checks the version and surfaces provider.data_flow at consent time.

Fields

§protocol_version: String
§provider: ProviderInfo
§capabilities: Capabilities
§

Query

Host → provider retrieval request (context/query).

Fields

§id: Option<String>

Correlation id. A provider MUST echo it on the reply.

§

Frames

Provider → host budgeted, provenance-carrying frames.

Fields

§id: Option<String>

The id of the query this answers, echoed verbatim.

§

Verify

Host → provider revalidation request: are these held frames still valid (docs/context-reuse.md §4 context/verify)? Carries frame identities only — never bodies. Capability-gated: a host sends it only to a provider advertising Capabilities::verify.

Fields

§

Verified

Provider → host per-frame verdicts.

Fields

§

Shutdown

Lifecycle teardown; the provider should exit cleanly.

§

Error

Provider-reported failure — lets a provider report a bad request without dying (SPEC.md §R1 “fail loud”). The host maps this to HostError::Provider.

Fields

§id: Option<String>

The id of the request that failed, when the failure is attributable to one.

§code: Option<ErrorCode>

Machine-readable classification (SPEC.md §Errors). Optional so that a provider written against an earlier revision stays conformant; a host treats its absence as ErrorCode::Internal.

§message: String

Human-readable detail. Always present: the code is for the machine, the message is for whoever reads the log.

Implementations§

Source§

impl Envelope

Source

pub fn correlation_id(&self) -> Option<&str>

The correlation id this envelope carries, if any.

None means one of two things, and the caller can tell them apart from context: either the envelope is a lifecycle message that never carries one (handshake, shutdown), or the peer does not implement correlation and the exchange must stay lock-step.

Source

pub fn error_code(&self) -> Option<ErrorCode>

The error code carried by an error envelope, defaulting to ErrorCode::Internal when the provider declared none.

Defaulting to Internal rather than to something retryable is the conservative reading: a host must not infer “safe to retry” from a provider’s silence.

Trait Implementations§

Source§

impl Clone for Envelope

Source§

fn clone(&self) -> Envelope

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 Envelope

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Envelope

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Envelope

Source§

fn eq(&self, other: &Envelope) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Envelope

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Envelope

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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 = 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