Skip to main content

HostContext

Struct HostContext 

Source
pub struct HostContext {
Show 14 fields pub project_root: PathBuf, pub mesh_agent: Option<Arc<MeshAgent>>, pub mcp_manager: Arc<RwLock<McpManager>>, pub http_client: Client, pub sql_conn: Arc<Mutex<Connection>>, pub sql_interrupt: Arc<InterruptHandle>, pub kv_conn: Arc<Mutex<Connection>>, pub kv_interrupt: Arc<InterruptHandle>, pub ts_conn: Arc<Mutex<Connection>>, pub ts_interrupt: Arc<InterruptHandle>, pub isle: Arc<AsyncIsle>, pub handler_isle: Arc<AsyncIsle>, pub bus_tx: Sender<Event>, pub event_bus: Arc<Mutex<Option<EventBus>>>,
}
Expand description

Shared context passed into Lua bridge functions.

Fields§

§project_root: PathBuf§mesh_agent: Option<Arc<MeshAgent>>§mcp_manager: Arc<RwLock<McpManager>>§http_client: Client

Shared async HTTP client for http.* bridge.

§sql_conn: Arc<Mutex<Connection>>

Shared SQLite connection for sql.* bridge (user tables).

§sql_interrupt: Arc<InterruptHandle>

Interrupt handle for the sql connection. Used to cancel in-flight queries on timeout (see bridge/sql.rs).

§kv_conn: Arc<Mutex<Connection>>

Shared SQLite connection for kv.* bridge (__kv table only). Separate from sql_conn so KV scratch state and user SQL data don’t share WAL, page cache, or backup lifecycle.

§kv_interrupt: Arc<InterruptHandle>

Interrupt handle for the kv connection.

§ts_conn: Arc<Mutex<Connection>>

Shared SQLite connection for ts.* bridge (TSDB — time-series table). Separate DB file so TSDB WAL does not share page cache with kv/sql.

§ts_interrupt: Arc<InterruptHandle>

Interrupt handle for the ts connection. Used by bridge::ts to cancel in-flight queries on timeout (Subtask 2).

§isle: Arc<AsyncIsle>

Async handle to the main Isle Lua VM that runs the user script via coroutine_eval. After Subtask 2, bridge::bus no longer dispatches handlers against this Isle; handlers live on handler_isle instead. The field is retained because bridge code still keyed to the main Isle (future coroutine_call back-edges, introspection APIs) may need it, and removing it would force another HostContext reshape.

§handler_isle: Arc<AsyncIsle>

Dedicated Isle for EventBus handler execution. Lua handlers registered via bus.on / bus.on_any run here so that CPU-bound handler code does not occupy the main Isle’s LocalSet and block grace timers / shutdown wakers on the main VM side.

Used by bridge::bus to forward handler bytecode (Function::dump(true)handler_isle.exec(...)) and by LuaHandler::call to dispatch via coroutine_call("__bus_dispatch", ...).

§bus_tx: Sender<Event>

Ingress sender for the EventBus. Adapters (mesh / webhook / …) clone this and push Events. The ST3 mesh adapter captures its own clone at MeshAgent::connect time, so the field itself is not read elsewhere in the ST3 cut — kept pub for ST4+ adapter wiring.

§event_bus: Arc<Mutex<Option<EventBus>>>

Mutex-wrapped Option<EventBus> so bus.on / bus.on_any can lock briefly from sync Lua context, and bus.serve can Option::take ownership before entering the long-lived run() await (avoiding the await-holding-lock anti-pattern on a std::sync::Mutex).

Trait Implementations§

Source§

impl Clone for HostContext

Source§

fn clone(&self) -> HostContext

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> MaybeSend for T

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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: Sized + 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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