pub struct AppState<S: Storage, P: Provider> {
pub registry: Arc<ArcSwap<ProviderRegistry<P>>>,
pub config: GatewayConfig,
pub extensions: Arc<Vec<Box<dyn Extension>>>,
pub storage: Arc<S>,
pub key_map: Arc<RwLock<HashMap<String, String>>>,
pub usage_events: Option<Sender<UsageEvent>>,
}Expand description
Shared application state passed to all handlers.
Generic over the storage backend S and the provider type P. The
binary picks P by defining a workspace-level union enum that wraps
every provider source it links — that enum implements Provider via
match-and-delegate, so dispatch through P is fully monomorphized.
Fields§
§registry: Arc<ArcSwap<ProviderRegistry<P>>>§config: GatewayConfig§extensions: Arc<Vec<Box<dyn Extension>>>§storage: Arc<S>§key_map: Arc<RwLock<HashMap<String, String>>>Precomputed token → key name lookup for O(1) auth. Wrapped in RwLock to support runtime key management.
usage_events: Option<Sender<UsageEvent>>Optional broadcast sink for per-request UsageEvents. None
is a no-op — the standalone crabllm serve binary leaves it
unset and behavior is unchanged. Embedders that want live
traffic construct a sender, pass Some(sender.clone()), and
call sender.subscribe() to observe events.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<S, P> !RefUnwindSafe for AppState<S, P>
impl<S, P> !UnwindSafe for AppState<S, P>
impl<S, P> Freeze for AppState<S, P>
impl<S, P> Send for AppState<S, P>
impl<S, P> Sync for AppState<S, P>
impl<S, P> Unpin for AppState<S, P>
impl<S, P> UnsafeUnpin for AppState<S, P>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more