#[non_exhaustive]pub struct ToolHooks {
pub max_result_bytes: Option<usize>,
pub before: Option<BeforeHook>,
pub after: Option<AfterHook>,
}Expand description
Opt-in hooks applied by crate::tool_hooks::HookedHandler.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.max_result_bytes: Option<usize>Hard cap on serialized CallToolResult size in bytes. When
exceeded, the result is replaced with an is_error=true result
carrying a result_too_large structured error. None disables
the cap.
before: Option<BeforeHook>Optional before-hook invoked after arg deserialization, before the wrapped handler is called.
after: Option<AfterHook>Optional after-hook invoked once per call, regardless of how the
call resolved. Spawned via tokio::spawn and never blocks the
response path.
Implementations§
Source§impl ToolHooks
impl ToolHooks
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct an empty ToolHooks with no cap and no hooks.
Use the with_* builder methods to populate fields; this avoids
the #[non_exhaustive] restriction that prevents struct-literal
construction from outside the crate.
Sourcepub fn with_max_result_bytes(self, max: usize) -> Self
pub fn with_max_result_bytes(self, max: usize) -> Self
Set the serialized result size cap in bytes.
Sourcepub fn with_before(self, before: BeforeHook) -> Self
pub fn with_before(self, before: BeforeHook) -> Self
Set the before-hook.
Sourcepub fn with_after(self, after: AfterHook) -> Self
pub fn with_after(self, after: AfterHook) -> Self
Set the after-hook.