Skip to main content

ContextProvider

Trait ContextProvider 

Source
pub trait ContextProvider: Send + Sync {
    // Required methods
    fn id(&self) -> &str;
    fn info(&self) -> &ProviderInfo;
    fn capabilities(&self) -> &Capabilities;
    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;

    // Provided methods
    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 shutdown<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), HostError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

A registered Context Graph Protocol provider, queryable behind one handle regardless of transport. info()/capabilities() return values cached at handshake time, so they are cheap synchronous getters even for out-of-process providers.

Required Methods§

Source

fn id(&self) -> &str

The provider’s host-facing id — its routing key and its consent key (SPEC.md §4 and §10).

Source

fn info(&self) -> &ProviderInfo

Identity + declared data-flow direction, surfaced at consent time (SPEC.md §3, ).

Source

fn capabilities(&self) -> &Capabilities

Capabilities negotiated at the handshake (SPEC.md §3) — which frame kinds and filters this provider serves, whether it upserts, does graph, is an embedder, or supports subscriptions.

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,

Answer a context query with budgeted, provenance-carrying frames (SPEC.md §5). The host — not the provider — enforces the budget and consent; a provider that over-runs its budget is caught by the host, not trusted (crate::host).

Provided Methods§

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,

Revalidate frames the host already holds, without any frame body travelling (docs/context-reuse.md §4 context/verify).

Defaults to answering Verdict::Unknown for every requested identity, so an existing provider implements nothing and is simply treated as unable to vouch for its frames — the host then re-queries them. A provider that overrides this MUST also advertise Capabilities::verify, since the host only asks providers that declare support.

Source

fn shutdown<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), HostError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Shut the provider down cleanly (SPEC.md §3 lifecycle). In-process providers default to a no-op; transport-backed providers send shutdown and reap their child. Overridable.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§