pub struct DispatchContext {
pub http: Option<HttpClient>,
pub engine: Arc<RwLock<EngineState>>,
pub state: Arc<dyn StateSource>,
pub sessions: Option<Arc<dyn SessionSource>>,
pub config: Option<Arc<dyn ConfigSource>>,
pub verbose: bool,
pub wrap_off: bool,
pub auto: Option<Arc<dyn AutoSource>>,
pub supervisor: Option<Arc<dyn SupervisorSource>>,
}Expand description
Shared context for dispatch. The HTTP client is optional — the TUI launches even when the engine is unreachable, and commands that need it degrade to a clear error line.
Fields§
§http: Option<HttpClient>§engine: Arc<RwLock<EngineState>>§state: Arc<dyn StateSource>Operator-state source. Defaults to StaticLabel::steady()
so freshly-constructed contexts never accidentally gate.
sessions: Option<Arc<dyn SessionSource>>Session store, if persistence is enabled. None when
--no-persist is set or the DB failed to open — the
session-cohort commands (/sessions, /resume, /fork,
/save) then surface a single “persistence disabled”
alert rather than pretending.
config: Option<Arc<dyn ConfigSource>>Config introspection source. None in tests + headless
paths; /config show|doctor then emit a single
“unavailable” alert rather than panicking. Wired in
production by zero/src/main.rs over zero_config.
verbose: boolCurrent verbose-rendering state, snapshotted at dispatch
time by the caller. Lets /verbose toggle resolve into
an absolute target without the dispatcher needing a
trait-level callback. Defaults to false so commands
that never touch verbosity do not need to set it.
wrap_off: boolCurrent wrap-off state, snapshotted at dispatch time.
Lets /wrap-off become a no-op (with honest wording)
when already disabled; mirrors verbose for the same
reason — dispatcher stays pure.
auto: Option<Arc<dyn AutoSource>>Engine Auto-mode source. None when the engine is
unreachable or no adapter has been installed — the
dispatcher then surfaces /auto as “unavailable”
rather than pretending. Wired in production by
crates/zero/src/main.rs atop the engine client.
supervisor: Option<Arc<dyn SupervisorSource>>Operator-local supervisor source. None when no
daemon adapter is installed — the dispatcher then
surfaces /headless as “unavailable” and /kill
falls through to the non-compound path. Wired by the
future zero-headless adapter (ADR-006).
Implementations§
Source§impl DispatchContext
impl DispatchContext
pub fn new(http: Option<HttpClient>, engine: Arc<RwLock<EngineState>>) -> Self
Sourcepub fn with_state(self, src: Arc<dyn StateSource>) -> Self
pub fn with_state(self, src: Arc<dyn StateSource>) -> Self
Override the operator-state source.
Sourcepub fn with_sessions(self, src: Arc<dyn SessionSource>) -> Self
pub fn with_sessions(self, src: Arc<dyn SessionSource>) -> Self
Attach a session store. Enables the session-cohort commands; without this they surface an “unavailable” alert.
Sourcepub fn with_config(self, src: Arc<dyn ConfigSource>) -> Self
pub fn with_config(self, src: Arc<dyn ConfigSource>) -> Self
Attach a config introspection source. Enables
/config show + /config doctor; without this they
surface an “unavailable” alert.
Sourcepub const fn with_verbose(self, on: bool) -> Self
pub const fn with_verbose(self, on: bool) -> Self
Snapshot the caller’s current verbose state so
/verbose toggle can resolve into an absolute target
without a round-trip to the TUI.
Sourcepub const fn with_wrap_off(self, on: bool) -> Self
pub const fn with_wrap_off(self, on: bool) -> Self
Snapshot the caller’s wrap-off state so /wrap-off
can surface an honest “already off” line without the
dispatcher calling back into the TUI.
Sourcepub fn with_auto(self, src: Arc<dyn AutoSource>) -> Self
pub fn with_auto(self, src: Arc<dyn AutoSource>) -> Self
Attach an Auto-mode source. Enables /auto on|off|status;
without this they surface an “unavailable” alert.
Sourcepub fn with_supervisor(self, src: Arc<dyn SupervisorSource>) -> Self
pub fn with_supervisor(self, src: Arc<dyn SupervisorSource>) -> Self
Attach a supervisor source. Enables
/headless start|stop|status and the /kill compound
tear-down. Without this /headless surfaces an
“unavailable” alert and /kill falls through to the
non-compound path.
Trait Implementations§
Source§impl Clone for DispatchContext
impl Clone for DispatchContext
Source§fn clone(&self) -> DispatchContext
fn clone(&self) -> DispatchContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more