pub struct DrawnEnvelope {
pub surface_id: String,
pub version: u64,
pub kind: DrawnKind,
pub catalog_id: String,
pub title: Option<String>,
pub messages: Vec<A2uiMessage>,
pub actions: Vec<DrawnAction>,
pub deleted: bool,
}Expand description
One drawing as a drawing tool’s result records it, under drawn: the A2UI messages that
rebuild the whole surface, and the actions its buttons ask for (spec 3.3 §6.1 genui).
§Example
use adk_surface::genui::{A2uiMessage, DrawnEnvelope, DrawnKind, FORMS_CATALOG_ID};
let envelope = DrawnEnvelope {
surface_id: "s".into(),
version: 1,
kind: DrawnKind::Card,
catalog_id: FORMS_CATALOG_ID.into(),
title: None,
messages: vec![A2uiMessage::create_surface("s")],
actions: Vec::new(),
deleted: false,
};
assert_eq!(envelope.digest(), envelope.clone().digest());
assert_eq!(envelope.digest().len(), 64);Fields§
§surface_id: StringThe surface.
version: u64Its version: one more than any earlier drawing of the surface in the session.
kind: DrawnKindWhat it is.
catalog_id: StringThe catalog it was checked against.
title: Option<String>The title above it.
messages: Vec<A2uiMessage>The A2UI messages that draw it: createSurface, updateComponents and
updateDataModel, or deleteSurface.
actions: Vec<DrawnAction>The actions its buttons ask for.
deleted: boolWhether this version removes the surface.
Implementations§
Source§impl DrawnEnvelope
impl DrawnEnvelope
Sourcepub fn digest(&self) -> String
pub fn digest(&self) -> String
The SHA-256 of the envelope’s canonical JSON (keys sorted), hex.
Sourcepub fn draft(&self) -> Option<SurfaceDraft>
pub fn draft(&self) -> Option<SurfaceDraft>
The drawing its messages describe, or None for a removal.
§Example
use adk_surface::genui::{A2uiMessage, DrawnEnvelope, DrawnKind, FORMS_CATALOG_ID};
use serde_json::json;
let envelope = DrawnEnvelope {
surface_id: "s".into(),
version: 1,
kind: DrawnKind::Card,
catalog_id: FORMS_CATALOG_ID.into(),
title: None,
messages: vec![
A2uiMessage::create_surface("s"),
A2uiMessage::update_components(
"s",
vec![json!({ "id": "root", "component": "Text", "text": { "path": "/t" } })],
),
A2uiMessage::update_data_model("s", None, Some(json!({ "t": "Hello" }))),
],
actions: Vec::new(),
deleted: false,
};
assert_eq!(envelope.draft().unwrap().data_model, json!({ "t": "Hello" }));Sourcepub fn from_response(response: &Value) -> Option<Self>
pub fn from_response(response: &Value) -> Option<Self>
The envelope a drawing tool’s response records under drawn, if any.
Sourcepub fn delta_from(&self, previous: &DrawnEnvelope) -> Option<Vec<A2uiMessage>>
pub fn delta_from(&self, previous: &DrawnEnvelope) -> Option<Vec<A2uiMessage>>
The A2UI messages that turn a renderer showing previous into one showing this
version: one updateComponents with the components that are new or changed, then an
updateDataModel for each data path that changed (no value where one was removed).
Empty when nothing changed. An envelope keeps the whole drawing, so its digest and
what a person approves stay whole; a transport that knows which version a renderer
holds (a socket, an A2A task) sends this instead of the whole drawing.
A2UI has no message that removes a component: a component dropped from the drawing is no longer referenced by its changed parent, so the renderer stops drawing it.
None when there is no sound base: either is a removal, they are different surfaces
or catalogs, or previous is not older.
§Example
use adk_surface::genui::{A2uiBody, A2uiMessage, DrawnEnvelope, DrawnKind, FORMS_CATALOG_ID};
use serde_json::json;
let version = |n: u64, total: i64| DrawnEnvelope {
surface_id: "s".into(), version: n, kind: DrawnKind::Screen,
catalog_id: FORMS_CATALOG_ID.into(), title: None,
messages: vec![
A2uiMessage::create_surface("s"),
A2uiMessage::update_components("s", vec![
json!({ "id": "root", "component": "Text", "text": { "path": "/total" } })]),
A2uiMessage::update_data_model("s", None, Some(json!({ "total": total, "currency": "USD" }))),
],
actions: Vec::new(), deleted: false,
};
let delta = version(2, 12).delta_from(&version(1, 10)).unwrap();
assert_eq!(delta.len(), 1);
let A2uiBody::UpdateDataModel(update) = &delta[0].body else { panic!() };
assert_eq!(update.path.as_deref(), Some("/total"));
assert_eq!(update.value, Some(json!(12)));Trait Implementations§
Source§impl Clone for DrawnEnvelope
impl Clone for DrawnEnvelope
Source§impl Debug for DrawnEnvelope
impl Debug for DrawnEnvelope
Source§impl<'de> Deserialize<'de> for DrawnEnvelope
impl<'de> Deserialize<'de> for DrawnEnvelope
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for DrawnEnvelope
impl JsonSchema for DrawnEnvelope
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for DrawnEnvelope
impl PartialEq for DrawnEnvelope
Source§impl Serialize for DrawnEnvelope
impl Serialize for DrawnEnvelope
impl StructuralPartialEq for DrawnEnvelope
Auto Trait Implementations§
impl Forget for DrawnEnvelope
impl Freeze for DrawnEnvelopewhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<A2uiMessage>: Freeze,
PhantomData<DrawnAction>: Freeze,
impl Move for DrawnEnvelope
impl RefUnwindSafe for DrawnEnvelope
impl Send for DrawnEnvelope
impl Sync for DrawnEnvelope
impl Unpin for DrawnEnvelope
impl UnsafeUnpin for DrawnEnvelopewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<A2uiMessage>: UnsafeUnpin,
PhantomData<DrawnAction>: UnsafeUnpin,
impl UnwindSafe for DrawnEnvelopewhere
RawVecInner: UnwindSafe,
BTreeMap<String, Value>: UnwindSafe,
BTreeMap<String, ActionArg>: UnwindSafe,
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
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> ⓘ
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> ⓘ
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