pub struct Validator { /* private fields */ }Expand description
Checks drawings against a catalog and rule 5 (spec 3.3 §7.4 rule 5).
§Example
use adk_surface::genui::{DrawnKind, RefusalKind, SurfaceDraft, Validator};
use serde_json::json;
let validator = Validator::forms();
let card = |text: &str| SurfaceDraft {
surface_id: "status".into(),
kind: DrawnKind::Card,
title: None,
components: vec![json!({ "id": "root", "component": "Text", "text": text })],
data_model: json!({}),
actions: Vec::new(),
};
assert!(validator.validate(&card("Invoice sent to ACME")).is_ok());
let refused = validator.validate(&card("Approved")).unwrap_err();
assert_eq!(refused.kind, RefusalKind::LooksLikeDecision);Implementations§
Source§impl Validator
impl Validator
Sourcepub fn with_bindable_tools(
self,
tools: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn with_bindable_tools( self, tools: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Accepts actions bound to tools only: the drawing agent’s own tools. Without it, an
action may name any tool but the kernel’s and the drawing tools, and the agent
refuses a tool it does not have when the person sends. Given twice, an action may
name only a tool both give. The render tools also take the drawing agent’s tools from
its runtime when it gives them (ToolContext::agent_tool_names).
Sourcepub fn validate(
&self,
draft: &SurfaceDraft,
) -> Result<ValidatedSurface, DrawRefusal>
pub fn validate( &self, draft: &SurfaceDraft, ) -> Result<ValidatedSurface, DrawRefusal>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Validator
impl !UnwindSafe for Validator
impl Forget for Validator
impl Freeze for Validator
impl Move for Validator
impl Send for Validator
impl Sync for Validatorwhere
RawVecInner: Sync,
NodeRef<Owned, String, Value, LeafOrInternal>: Sync,
BoxRaw<(String, Value)>: Sync,
NodeRef<Owned, String, Validator, LeafOrInternal>: Sync,
BoxRaw<(String, Validator)>: Sync,
NodeRef<Owned, String, Arc<dyn ExtensionComponent>, LeafOrInternal>: Sync,
BoxRaw<(String, Arc<dyn ExtensionComponent>)>: Sync,
NodeRef<Owned, String, SetValZST, LeafOrInternal>: Sync,
BoxRaw<(String, SetValZST)>: Sync,
impl Unpin for Validator
impl UnsafeUnpin for Validatorwhere
&'static Catalog: UnsafeUnpin,
*const LeafNode<String, SetValZST> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, SetValZST)>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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