pub trait CredentialBroker: Send + Sync {
// Required methods
fn access_token<'life0, 'async_trait>(
&'life0 self,
provider: OAuthProviderId,
) -> Pin<Box<dyn Future<Output = Result<AccessToken, BrokerError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn proxy<'life0, 'async_trait>(
&'life0 self,
request: ProxyRequest,
) -> Pin<Box<dyn Future<Output = Result<ProxyResponse, BrokerError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn proxy_stream<'life0, 'async_trait>(
&'life0 self,
request: ProxyRequest,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Bytes, BrokerError>> + Send>>, BrokerError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn anthropic_usage<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Value, BrokerError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn capabilities<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ProviderStatus>, BrokerError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
// Provided methods
fn cloud_catalog<'life0, 'life1, 'async_trait>(
&'life0 self,
provider: CloudProviderId,
context_ref: &'life1 str,
allow_stale: bool,
) -> Pin<Box<dyn Future<Output = Result<Vec<CloudCatalogEntry>, BrokerError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait { ... }
fn cloud_invoke<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
provider: CloudProviderId,
context_ref: &'life1 str,
model_id: &'life2 str,
request: InvokeRequest,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<CloudEvent, BrokerError>> + Send>>, BrokerError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait { ... }
}Expand description
The typed credential broker protocol. One implementation runs in-process
(LocalBroker) so normal local use needs no daemon; the other talks to a
remote synaps auth-broker over authenticated HTTP(S) (RemoteBroker).
Required Methods§
Sourcefn access_token<'life0, 'async_trait>(
&'life0 self,
provider: OAuthProviderId,
) -> Pin<Box<dyn Future<Output = Result<AccessToken, BrokerError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn access_token<'life0, 'async_trait>(
&'life0 self,
provider: OAuthProviderId,
) -> Pin<Box<dyn Future<Output = Result<AccessToken, BrokerError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Vend a fresh OAuth access token (token + expiry ONLY).
Sourcefn proxy<'life0, 'async_trait>(
&'life0 self,
request: ProxyRequest,
) -> Pin<Box<dyn Future<Output = Result<ProxyResponse, BrokerError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn proxy<'life0, 'async_trait>(
&'life0 self,
request: ProxyRequest,
) -> Pin<Box<dyn Future<Output = Result<ProxyResponse, BrokerError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Execute a non-streaming provider request with the broker-owned key.
Sourcefn proxy_stream<'life0, 'async_trait>(
&'life0 self,
request: ProxyRequest,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Bytes, BrokerError>> + Send>>, BrokerError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn proxy_stream<'life0, 'async_trait>(
&'life0 self,
request: ProxyRequest,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Bytes, BrokerError>> + Send>>, BrokerError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Execute a streaming (SSE) provider request with the broker-owned key.
Returns the byte stream only when the upstream response is successful;
error statuses are read (bounded) and surfaced as BrokerError.
Sourcefn anthropic_usage<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Value, BrokerError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn anthropic_usage<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Value, BrokerError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Typed operation: fetch the Anthropic account-usage summary.
The destination URL is pinned broker-side and the OAuth access token
is resolved and attached behind the boundary — callers receive usage
JSON only and never see a token or auth.json. This is deliberately
NOT a generic OAuth proxy: one operation, one fixed endpoint.
Sourcefn capabilities<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ProviderStatus>, BrokerError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn capabilities<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ProviderStatus>, BrokerError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Non-secret provider capability/status list.
Provided Methods§
Sourcefn cloud_catalog<'life0, 'life1, 'async_trait>(
&'life0 self,
provider: CloudProviderId,
context_ref: &'life1 str,
allow_stale: bool,
) -> Pin<Box<dyn Future<Output = Result<Vec<CloudCatalogEntry>, BrokerError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn cloud_catalog<'life0, 'life1, 'async_trait>(
&'life0 self,
provider: CloudProviderId,
context_ref: &'life1 str,
allow_stale: bool,
) -> Pin<Box<dyn Future<Output = Result<Vec<CloudCatalogEntry>, BrokerError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Typed cloud catalog. Credentials and provider authority remain broker-owned.
Sourcefn cloud_invoke<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
provider: CloudProviderId,
context_ref: &'life1 str,
model_id: &'life2 str,
request: InvokeRequest,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<CloudEvent, BrokerError>> + Send>>, BrokerError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn cloud_invoke<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
provider: CloudProviderId,
context_ref: &'life1 str,
model_id: &'life2 str,
request: InvokeRequest,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<CloudEvent, BrokerError>> + Send>>, BrokerError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Typed cloud invocation. The canonical model and normalized request are the only caller-controlled inputs; hosts, auth and signing remain broker-owned.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".