pub struct RawStdioConnection { /* private fields */ }Expand description
A raw, framed connection to a child-process Context Graph Protocol provider. The low-level
primitive StdioProvider is built on; public so conformance tools can
drive the wire directly.
Implementations§
Source§impl RawStdioConnection
impl RawStdioConnection
Sourcepub async fn spawn(program: &str, args: &[String]) -> Result<Self, HostError>
pub async fn spawn(program: &str, args: &[String]) -> Result<Self, HostError>
Spawn program with args as a CGP provider child, under the
isolation contract (scrubbed env, own process group). Does not
handshake — call RawStdioConnection::handshake next.
Sourcepub fn with_label(self, label: impl Into<String>) -> Self
pub fn with_label(self, label: impl Into<String>) -> Self
Override the connection’s error label (defaults to the program name).
StdioProvider sets it to the provider’s host-facing id.
Sourcepub async fn send(&mut self, env: &Envelope) -> Result<(), HostError>
pub async fn send(&mut self, env: &Envelope) -> Result<(), HostError>
Send one envelope as an NDJSON line.
Sourcepub async fn send_raw_line(&mut self, line: &str) -> Result<(), HostError>
pub async fn send_raw_line(&mut self, line: &str) -> Result<(), HostError>
Write a raw line to the provider’s stdin verbatim — the escape hatch
conformance uses to inject a malformed line (SPEC.md §11). A trailing \n is
appended if missing so the provider’s line reader unblocks.
Sourcepub async fn read_raw_line(&mut self) -> Result<Option<String>, HostError>
pub async fn read_raw_line(&mut self) -> Result<Option<String>, HostError>
Read the next raw line, or None at EOF (the child closed stdout).
Bounded to [MAX_LINE_BYTES] via an incremental fill_buf/consume
loop: a buggy or hostile child that streams bytes without ever emitting
a newline would otherwise grow a single String without limit (the
handshake/query timeouts bound time, not memory) and OOM the host.
Sourcepub async fn recv(&mut self) -> Result<Envelope, HostError>
pub async fn recv(&mut self) -> Result<Envelope, HostError>
Read the next envelope. A closed stream (the child died) is
HostError::ProviderCrashed — never a hang or a panic
(task deliverable 5).
Sourcepub async fn handshake(
&mut self,
) -> Result<(ProviderInfo, Capabilities), HostError>
pub async fn handshake( &mut self, ) -> Result<(ProviderInfo, Capabilities), HostError>
Perform the Context Graph Protocol handshake (SPEC.md §3): send handshake, expect
handshake_ack, and reject an incompatible protocol version with a
named error. Bounded by [HANDSHAKE_TIMEOUT] so a silent provider
fails cleanly rather than hanging (task deliverable 1).