pub struct DynamicSourcePolicy { /* private fields */ }Expand description
Reusable policy for dynamic source evaluated through a named codec.
The policy fixes only the source provenance and codec. Authority and the
expected result shape remain explicit inputs to every evaluation, so a
guest-language wrapper cannot accidentally retain or widen either one.
Callers that need origin detail must provide it in RequestOrigin when
constructing the policy.
Implementations§
Source§impl DynamicSourcePolicy
impl DynamicSourcePolicy
Sourcepub fn new(codec: Symbol, origin: RequestOrigin) -> Self
pub fn new(codec: Symbol, origin: RequestOrigin) -> Self
Builds a policy with its own decision ledger.
Sourcepub fn with_broker(
broker: ReadEvalBroker,
codec: Symbol,
origin: RequestOrigin,
) -> Self
pub fn with_broker( broker: ReadEvalBroker, codec: Symbol, origin: RequestOrigin, ) -> Self
Builds a policy over an existing broker.
Cloned brokers share their ledger, allowing several origin/codec policies to expose one ordered decision stream.
Sourcepub fn evaluate_text(
&self,
cx: &mut Cx,
text: impl Into<String>,
authority: SourceAuthority,
expected_shape: Arc<dyn Shape>,
) -> Result<Value>
pub fn evaluate_text( &self, cx: &mut Cx, text: impl Into<String>, authority: SourceAuthority, expected_shape: Arc<dyn Shape>, ) -> Result<Value>
Evaluates text decoded through this policy’s codec.
Sourcepub fn evaluate_bytes(
&self,
cx: &mut Cx,
bytes: impl Into<Vec<u8>>,
authority: SourceAuthority,
expected_shape: Arc<dyn Shape>,
) -> Result<Value>
pub fn evaluate_bytes( &self, cx: &mut Cx, bytes: impl Into<Vec<u8>>, authority: SourceAuthority, expected_shape: Arc<dyn Shape>, ) -> Result<Value>
Evaluates bytes decoded through this policy’s codec.
Sourcepub fn evaluate_expr(
&self,
cx: &mut Cx,
expr: Expr,
authority: SourceAuthority,
expected_shape: Arc<dyn Shape>,
) -> Result<Value>
pub fn evaluate_expr( &self, cx: &mut Cx, expr: Expr, authority: SourceAuthority, expected_shape: Arc<dyn Shape>, ) -> Result<Value>
Evaluates an already-decoded expression through the same admission gate.
Sourcepub fn evaluate(
&self,
cx: &mut Cx,
source: ReadEvalSource,
authority: SourceAuthority,
expected_shape: Arc<dyn Shape>,
) -> Result<Value>
pub fn evaluate( &self, cx: &mut Cx, source: ReadEvalSource, authority: SourceAuthority, expected_shape: Arc<dyn Shape>, ) -> Result<Value>
Evaluates any supported source form through the shared broker law.
Sourcepub fn decisions(&self, cx: &Cx) -> Result<Vec<ReadEvalDecision>>
pub fn decisions(&self, cx: &Cx) -> Result<Vec<ReadEvalDecision>>
Returns decisions recorded in the policy’s default run.
Sourcepub fn decisions_for_run(
&self,
cx: &Cx,
run: &Ref,
) -> Result<Vec<ReadEvalDecision>>
pub fn decisions_for_run( &self, cx: &Cx, run: &Ref, ) -> Result<Vec<ReadEvalDecision>>
Returns decisions recorded for run.
Trait Implementations§
Source§impl Clone for DynamicSourcePolicy
impl Clone for DynamicSourcePolicy
Source§fn clone(&self) -> DynamicSourcePolicy
fn clone(&self) -> DynamicSourcePolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more