pub struct StdioProvider { /* private fields */ }Expand description
A ContextProvider backed by a child process over stdio.
Handshakes once on construction, caches the negotiated identity +
capabilities, then splits the connection into independently-lockable halves:
the write half (stdin) is locked only for the length of one line write, a
dedicated reader task owns the read half and demultiplexes replies on their
correlation id, and a [StdioControl] holds the child for teardown. A
provider that negotiated Capabilities::correlation
can therefore have several querys in flight at once — a slow one no longer
head-of-line blocks the rest. A provider that did not negotiate
correlation, and every verify (whose envelopes carry no id and so cannot
be demultiplexed), stay strictly lock-step via no_id_lock, behaving exactly
as the single-mutex transport did before (ADR 0002).
Implementations§
Source§impl StdioProvider
impl StdioProvider
Sourcepub async fn spawn(
id: impl Into<String>,
program: &str,
args: &[String],
) -> Result<Self, HostError>
pub async fn spawn( id: impl Into<String>, program: &str, args: &[String], ) -> Result<Self, HostError>
Spawn a child-process provider, complete the handshake, and cache its
declared identity + capabilities. id is the host-facing routing and
consent key. Fails cleanly (killing the child) on a bad or incompatible
handshake. On success the connection is split and the reader task
launched, so replies can be demultiplexed from here on.
Trait Implementations§
Source§impl ContextProvider for StdioProvider
impl ContextProvider for StdioProvider
Source§fn id(&self) -> &str
fn id(&self) -> &str
SPEC.md §4 and §10).Source§fn info(&self) -> &ProviderInfo
fn info(&self) -> &ProviderInfo
Source§fn capabilities(&self) -> &Capabilities
fn capabilities(&self) -> &Capabilities
Source§fn query<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 ContextQuery,
) -> Pin<Box<dyn Future<Output = Result<ContextQueryResult, HostError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn query<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 ContextQuery,
) -> Pin<Box<dyn Future<Output = Result<ContextQueryResult, HostError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
crate::host).Source§fn verify<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 VerifyRequest,
) -> Pin<Box<dyn Future<Output = Result<VerifyResponse, HostError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn verify<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 VerifyRequest,
) -> Pin<Box<dyn Future<Output = Result<VerifyResponse, HostError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
docs/context-reuse.md §4 context/verify). Read moreSource§fn shutdown<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), HostError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn shutdown<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), HostError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
shutdown and
reap their child. Overridable.