Skip to main content

DispatchContext

Struct DispatchContext 

Source
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: bool

Current 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: bool

Current 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

Source

pub fn new(http: Option<HttpClient>, engine: Arc<RwLock<EngineState>>) -> Self

Source

pub fn with_state(self, src: Arc<dyn StateSource>) -> Self

Override the operator-state source.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> DispatchContext

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DispatchContext

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more