Struct Part
pub struct Part {
pub text: Option<String>,
pub raw: Option<String>,
pub url: Option<String>,
pub data: Option<Value>,
pub metadata: Option<Value>,
pub filename: Option<String>,
pub media_type: Option<String>,
}Expand description
A2A Part (proto message Part) — a section of communication content.
The content oneof is expressed without a discriminator: the active
branch is exactly one of text / raw / url / data; the shared
optional fields (metadata/filename/mediaType) ride alongside it.
The oneof invariant is enforced at deserialization (via
deserialize_part): a payload with zero content branches or more than
one is rejected, matching the proto oneof semantics (spec §5.7 — a
Part carries exactly one content branch). A struct (not an enum) lets
serde handle the field-name-keyed shape directly while a custom
deserializer validates the oneof invariant.
Fields§
§text: Option<String>§raw: Option<String>base64-encoded bytes (proto bytes JSON form).
url: Option<String>§data: Option<Value>§metadata: Option<Value>§filename: Option<String>§media_type: Option<String>Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Part
impl<'de> Deserialize<'de> for Part
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Enforce the proto oneof content invariant: exactly one of
text / raw / url / data must be present. Zero branches (empty
Part) or multiple branches are rejected, matching proto oneof
semantics (spec §5.7 — a Part carries exactly one content branch).
{"data": null} is accepted: the data key is present, so the data
branch is selected (proto3 oneof uses key presence, not value
nullness).
Source§impl JsonSchema for Part
impl JsonSchema for Part
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 more