#[non_exhaustive]pub struct UserMessage {
pub message_id: MessageId,
pub content: MaybeUndefined<Vec<ContentBlock>>,
pub meta: MaybeUndefined<Meta>,
}unstable_protocol_v2 only.Expand description
A user message upsert.
Only UserMessage::message_id is required. content has patch semantics:
an omitted field leaves existing message content unchanged, null clears the
value, and a concrete array replaces the previous value. For a new
messageId, omitted fields use client defaults. content is replaced as a
whole array; send [] or null to clear it.
Message updates and chunks are applied in the order they are received. When
a user_message update includes content, that array replaces any content
previously accumulated for the message, including content from earlier
chunks. Later chunks with the same messageId append to the current
content.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.message_id: MessageIdA unique identifier for the message.
content: MaybeUndefined<Vec<ContentBlock>>Complete replacement content for this message.
meta: MaybeUndefined<Meta>The _meta property is reserved by ACP to allow clients and agents to attach additional
metadata to their interactions. Omitted leaves the stored metadata unchanged; null
clears it. An object patches the stored metadata by top-level key: keys it omits are
unchanged, a key set to null is removed, and any other value replaces that key’s
stored value without merging nested objects. Beyond this patch rule, implementations
MUST NOT make assumptions about values at these keys.
See protocol docs: Metadata Patches
Implementations§
Source§impl UserMessage
impl UserMessage
Sourcepub fn new(message_id: impl Into<MessageId>) -> Self
pub fn new(message_id: impl Into<MessageId>) -> Self
Builds UserMessage with the required fields set; optional fields start unset or empty.
Sourcepub fn content(
self,
content: impl IntoMaybeUndefined<Vec<ContentBlock>>,
) -> Self
pub fn content( self, content: impl IntoMaybeUndefined<Vec<ContentBlock>>, ) -> Self
Complete replacement content for this message.
Sourcepub fn meta(self, meta: impl IntoMaybeUndefined<Meta>) -> Self
pub fn meta(self, meta: impl IntoMaybeUndefined<Meta>) -> Self
Patches, clears, or leaves unchanged message metadata.
A concrete object patches stored metadata by top-level key; see
apply_meta_update.
Trait Implementations§
Source§impl Clone for UserMessage
impl Clone for UserMessage
Source§impl Debug for UserMessage
impl Debug for UserMessage
Source§impl<'de> Deserialize<'de> for UserMessage
impl<'de> Deserialize<'de> for UserMessage
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>,
impl Eq for UserMessage
Source§impl JsonSchema for UserMessage
impl JsonSchema for UserMessage
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 UserMessage
impl PartialEq for UserMessage
Source§impl Serialize for UserMessage
impl Serialize for UserMessage
impl StructuralPartialEq for UserMessage
Auto Trait Implementations§
impl Freeze for UserMessage
impl RefUnwindSafe for UserMessage
impl Send for UserMessage
impl Sync for UserMessage
impl Unpin for UserMessage
impl UnsafeUnpin for UserMessage
impl UnwindSafe for UserMessage
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
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.