Skip to main content

TokenSource

Trait TokenSource 

Source
pub trait TokenSource: Send + Sync {
    // Required method
    fn mint(&self) -> Result<MintedToken>;

    // Provided method
    fn describe(&self) -> String { ... }
}
Expand description

Anything that can produce a bearer token for the client.

Implementors must be Send + Sync because the client caches tokens behind a mutex and is shared across tasks.

Required Methods§

Source

fn mint(&self) -> Result<MintedToken>

Mint a fresh token. The client calls this lazily and caches the result until shortly before it expires, so this need not be cheap.

Provided Methods§

Source

fn describe(&self) -> String

A short, secret-free description for diagnostics and MCP transcripts. Must never contain key or token material — it may be logged or surfaced to a user. Defaults to the type’s shape.

Trait Implementations§

Source§

impl Debug for dyn TokenSource

Source§

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

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

impl IntoTokenSource for Box<dyn TokenSource>

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§