Skip to main content

zagens_runtime_api/
state.rs

1//! Shared state ports for auth, probe, and router composition (D16 E1-c phase 2).
2
3/// Bearer token gate for `/v1/*` routes.
4pub trait RuntimeApiAuthState: Clone + Send + Sync + 'static {
5    fn runtime_token(&self) -> Option<&str>;
6}
7
8/// `/internal/probe` fields supplied by the sidecar host.
9pub trait RuntimeApiProbeState: Clone + Send + Sync + 'static {
10    fn process_started_at_ms(&self) -> u128;
11
12    fn token_fingerprint(&self) -> &str;
13
14    fn service_version(&self) -> &'static str;
15}
16
17/// Combined bounds for [`crate::router::compose_router`].
18pub trait RuntimeApiHostState: RuntimeApiAuthState + RuntimeApiProbeState {}
19
20impl<T> RuntimeApiHostState for T where T: RuntimeApiAuthState + RuntimeApiProbeState {}