pub enum ContentPart {
Text {
text: String,
},
Reasoning {
text: String,
},
FileData {
file_uri: String,
mime_type: Option<String>,
},
InlineData {
mime_type: String,
data: ByteBufB64,
},
ToolCall {
name: String,
args: Json,
call_id: Option<String>,
},
ToolOutput {
name: String,
output: Json,
is_error: Option<bool>,
call_id: Option<String>,
remote_id: Option<Principal>,
},
Action {
name: String,
payload: Json,
recipients: Option<Vec<Principal>>,
signature: Option<ByteBufB64>,
},
Any(Json),
}Expand description
A single content item inside a chat message.
The enum supports Anda’s normalized content types while preserving unknown
provider-specific JSON payloads in ContentPart::Any.
Variants§
Text
Visible text content.
Reasoning
Provider reasoning or thinking text.
FileData
File content referenced by URI.
InlineData
Inline binary data with an explicit MIME type.
Fields
data: ByteBufB64Base64-encoded binary payload.
ToolCall
Tool call requested by a model.
Fields
ToolOutput
Tool output returned to a model.
Fields
Action
Signed action payload emitted by an agent.
Fields
signature: Option<ByteBufB64>Optional signature over the action payload.
Any(Json)
Provider-specific content part preserved as raw JSON.
Implementations§
Source§impl ContentPart
impl ContentPart
Sourcepub fn any_from<T>(ty: &str, val: T) -> Selfwhere
T: Serialize,
pub fn any_from<T>(ty: &str, val: T) -> Selfwhere
T: Serialize,
Creates a content part of type Any with the given type tag and value.
The type tag is only added when val serializes to a JSON object.
Sourcepub fn any_into<T>(self, ty: &str) -> Result<T, Box<Self>>where
T: DeserializeOwned,
pub fn any_into<T>(self, ty: &str) -> Result<T, Box<Self>>where
T: DeserializeOwned,
Attempts to convert this content part of type Any into the specified type if the type tag matches.
Sourcepub fn estimated_tokens(&self) -> usize
pub fn estimated_tokens(&self) -> usize
Estimates the number of tokens in this content part for usage accounting and pruning.
Trait Implementations§
Source§impl Clone for ContentPart
impl Clone for ContentPart
Source§fn clone(&self) -> ContentPart
fn clone(&self) -> ContentPart
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ContentPart
impl Debug for ContentPart
Source§impl<'de> Deserialize<'de> for ContentPart
impl<'de> Deserialize<'de> for ContentPart
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 ContentPart
Source§impl From<String> for ContentPart
impl From<String> for ContentPart
Source§impl From<Value> for ContentPart
impl From<Value> for ContentPart
Source§impl PartialEq for ContentPart
impl PartialEq for ContentPart
Source§impl Serialize for ContentPart
impl Serialize for ContentPart
impl StructuralPartialEq for ContentPart
Auto Trait Implementations§
impl Freeze for ContentPart
impl RefUnwindSafe for ContentPart
impl Send for ContentPart
impl Sync for ContentPart
impl Unpin for ContentPart
impl UnsafeUnpin for ContentPart
impl UnwindSafe for ContentPart
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
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<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.