pub struct PolicyState { /* private fields */ }Expand description
A policy whose per-tool JSON Schema validators are compiled ONCE, so a caller evaluating many tool
calls against the same policy does not recompile per call (jsonschema::validator_for is the
expensive step). evaluate_tool_args stays the one-shot convenience that compiles on the fly; this
is the compile-once path for hot loops, matching how the MCP proxy compiles all schemas at policy
load. Verdicts are identical to evaluate_tool_args for the same policy and call.
Implementations§
Source§impl PolicyState
impl PolicyState
Sourcepub fn compile(policy: &Value) -> Self
pub fn compile(policy: &Value) -> Self
Compile every tool schema in the policy once. A tool whose schema fails to compile is recorded
as an error and only surfaces (as E_SCHEMA_COMPILE) if that tool is later evaluated, matching
the one-shot evaluate_tool_args behavior of only compiling the requested tool’s schema.
Auto Trait Implementations§
impl !RefUnwindSafe for PolicyState
impl !UnwindSafe for PolicyState
impl Freeze for PolicyState
impl Send for PolicyState
impl Sync for PolicyState
impl Unpin for PolicyState
impl UnsafeUnpin for PolicyState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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