pub struct AppState {Show 27 fields
pub payloads: RwLock<Payloads>,
pub wire: RwLock<HashMap<&'static str, Bytes>>,
pub wire_off: AtomicBool,
pub reloader: RwLock<Option<ConfigReloader>>,
pub sessions: RwLock<HashMap<String, Value>>,
pub paths: Value,
pub auth: Option<(String, String)>,
pub requests: AtomicU64,
pub bus: EventBus,
pub db: PathBuf,
pub blobs: Arc<BlobStore>,
pub writer: Arc<Writer>,
pub llm: RwLock<LlmRegistry>,
pub watch: RwLock<WatchState>,
pub reconcile_lock: Mutex<()>,
pub max_rounds: usize,
pub cost_ceiling: f64,
pub gate: Arc<PermissionGate>,
pub mcp: OnceLock<Arc<McpHub>>,
pub plugins: OnceLock<Arc<Mutex<Sidecar>>>,
pub prompt_locks: Arc<Mutex<HashMap<String, Arc<Mutex<()>>>>>,
pub prompt_tasks: Arc<Mutex<HashMap<String, PromptTask>>>,
pub prompt_gen: Arc<AtomicU64>,
pub question_gate: Arc<QuestionGate>,
pub tui: TuiControl,
pub ui: UiProxy,
pub cors_extra: Vec<String>,
}Expand description
App state shared by handlers.
Fields§
§payloads: RwLock<Payloads>Config-derived route payloads (W4: swappable after PATCH /config — upstream marks the instance for disposal and serves fresh config).
wire: RwLock<HashMap<&'static str, Bytes>>PERF-10X F5: pre-serialized bytes for the hot Json-clone handlers (config/agent/command/config_providers/provider/console/capabilities). Built at construction + every reload, so a request is a Bytes clone (refcount) + zero-copy Body — no per-request Value clone/serialize. Kill-switch: OCSERVE_WIRE_CACHE=0 (wire_off) falls back to the Value path; both paths serve serde-identical bytes (unit-tested).
wire_off: AtomicBool§reloader: RwLock<Option<ConfigReloader>>Boot-injected config reloader (Runtime lives in ocserve; the closure avoids a crate cycle). None in tests → PATCH still writes the file, swap skipped (logged).
sessions: RwLock<HashMap<String, Value>>Known sessions (M1: served from store as it comes online).
paths: ValueRuntime paths for GET /path (env-derived at boot; never stored in repo).
auth: Option<(String, String)>Auth mode: None = off (freeze default), Some((“user”,“pass”)) = basic.
requests: AtomicU64Request counter for /metrics (bounded, monotonic).
bus: EventBusBounded broadcast of encoded global-event frames.
db: PathBuf§blobs: Arc<BlobStore>§writer: Arc<Writer>§llm: RwLock<LlmRegistry>Provider registry + default model + agent systems (from Runtime). RwLock since H2: rebuilds on config hot-reload (watch::reconcile); in-flight prompts keep the values they resolved at build time.
watch: RwLock<WatchState>Config hot-reload watch state (H1): polled paths + observed tuples.
reconcile_lock: Mutex<()>Serializes reconcile across PATCH/auth/watcher callers (tokio Mutex — held across reload + MCP awaits; never a parking_lot guard over await).
max_rounds: usizeK-AUTONOMY knobs — read from env ONCE at construction (changing OCSERVE_PROMPT_MAX_ROUNDS / OCSERVE_PROMPT_MAX_COST_USD = restart).
cost_ceiling: f64§gate: Arc<PermissionGate>Permission rendezvous shared by runner + reply routes.
mcp: OnceLock<Arc<McpHub>>MCP hub probed at serve boot (OnceLock: tests run without probing).
plugins: OnceLock<Arc<Mutex<Sidecar>>>Plugin sidecar (M4b): async mutex — trigger() takes &mut across await.
prompt_locks: Arc<Mutex<HashMap<String, Arc<Mutex<()>>>>>Per-session prompt serialization (queue semantics). Bounded: entries exist only for in-flight prompts + transient races, removed post-run when uncontended (AGENTS §2.3 — active-set bound, no eviction).
prompt_tasks: Arc<Mutex<HashMap<String, PromptTask>>>Background prompt tasks per session: (generation, JoinHandle) — POST /abort cancels the current generation (v1 session.abort). Bound: one entry per in-flight async prompt, removed on completion.
prompt_gen: Arc<AtomicU64>Monotonic generation source for prompt_tasks.
question_gate: Arc<QuestionGate>Question rendezvous (v1 Question service): pending asks + reply/reject.
tui: TuiControl/tui/control rendezvous queues (v1 shared/tui-control.ts)
ui: UiProxyWeb-UI reverse proxy (Phase 7; upstream serveUIEffect parity)
cors_extra: Vec<String>User CORS allowlist (config server.cors + --cors), read once at boot
Implementations§
Source§impl AppState
impl AppState
pub fn new() -> Arc<Self> ⓘ
pub fn with_auth(auth: Option<(String, String)>) -> Arc<Self> ⓘ
Auto Trait Implementations§
impl !Freeze for AppState
impl !RefUnwindSafe for AppState
impl !UnwindSafe for AppState
impl Send for AppState
impl Sync for AppState
impl Unpin for AppState
impl UnsafeUnpin for AppState
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
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);