Skip to main content

DefaultHandler

Struct DefaultHandler 

Source
pub struct DefaultHandler {
    pub sink: Box<dyn IoSink>,
    pub read_root: Option<PathBuf>,
    pub budget_used: RefCell<u64>,
    pub program: Option<Arc<Program>>,
    pub chat_registry: Option<Arc<ChatRegistry>>,
    pub mcp_clients: McpClientCache,
    /* private fields */
}

Fields§

§sink: Box<dyn IoSink>§read_root: Option<PathBuf>

Optional read root for io.read — when set, io.read("p") resolves to read_root.join(p). Lets tests run without touching the real fs.

§budget_used: RefCell<u64>

Captured budget consumption (post-static-check, observability only).

§program: Option<Arc<Program>>

Shared reference to the program, needed by net.serve so the handler can spin up fresh VMs to dispatch incoming requests. None if the handler was constructed without a program.

§chat_registry: Option<Arc<ChatRegistry>>

Chat registry; populated by net.serve_ws’s per-message dispatch so chat.broadcast / chat.send work from inside a handler invocation.

§mcp_clients: McpClientCache

LRU cache of agent.call_mcp clients keyed by the command-line string (#197). Avoids spawn-per-call cost when an agent invokes the same MCP server in tight loops. Capped — when the cache is full, the least-recently-used entry is dropped (its subprocess is reaped on Drop).

Implementations§

Source§

impl DefaultHandler

Source

pub fn new(policy: Policy) -> Self

Source

pub fn with_program(self, program: Arc<Program>) -> Self

Source

pub fn with_chat_registry(self, registry: Arc<ChatRegistry>) -> Self

Source

pub fn with_sink(self, sink: Box<dyn IoSink>) -> Self

Source

pub fn with_read_root(self, root: PathBuf) -> Self

Trait Implementations§

Source§

impl EffectHandler for DefaultHandler

Source§

fn dispatch( &mut self, kind: &str, op: &str, args: Vec<Value>, ) -> Result<Value, String>

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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