pub enum InputContent {
Text {
text: String,
},
Binary {
mime_type: String,
id: Option<String>,
url: Option<String>,
data: Option<String>,
filename: Option<String>,
},
}Expand description
Input content union type for multimodal messages.
This is a discriminated union that can hold either text or binary content.
The type field in JSON determines which variant is used.
§Example
use ag_ui_core::InputContent;
// Create text content
let text = InputContent::text("Hello!");
assert!(text.is_text());
// Create binary content with URL
let binary = InputContent::binary_with_url("image/jpeg", "https://example.com/img.jpg");
assert!(binary.is_binary());Variants§
Implementations§
Source§impl InputContent
impl InputContent
Sourcepub fn text(text: impl Into<String>) -> InputContent
pub fn text(text: impl Into<String>) -> InputContent
Creates a text content variant.
Sourcepub fn binary(mime_type: impl Into<String>) -> InputContent
pub fn binary(mime_type: impl Into<String>) -> InputContent
Creates a minimal binary content variant.
Sourcepub fn binary_with_url(
mime_type: impl Into<String>,
url: impl Into<String>,
) -> InputContent
pub fn binary_with_url( mime_type: impl Into<String>, url: impl Into<String>, ) -> InputContent
Creates a binary content variant with a URL.
Sourcepub fn binary_with_data(
mime_type: impl Into<String>,
data: impl Into<String>,
) -> InputContent
pub fn binary_with_data( mime_type: impl Into<String>, data: impl Into<String>, ) -> InputContent
Creates a binary content variant with base64-encoded data.
Sourcepub fn validate(&self) -> Result<(), ContentValidationError>
pub fn validate(&self) -> Result<(), ContentValidationError>
Validates the content.
For text content, always succeeds. For binary content, validates that at least one of id, url, or data is present.
Trait Implementations§
Source§impl Clone for InputContent
impl Clone for InputContent
Source§fn clone(&self) -> InputContent
fn clone(&self) -> InputContent
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for InputContent
impl Debug for InputContent
Source§impl<'de> Deserialize<'de> for InputContent
impl<'de> Deserialize<'de> for InputContent
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<InputContent, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<InputContent, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for InputContent
impl PartialEq for InputContent
Source§impl Serialize for InputContent
impl Serialize for InputContent
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for InputContent
Auto Trait Implementations§
impl Freeze for InputContent
impl RefUnwindSafe for InputContent
impl Send for InputContent
impl Sync for InputContent
impl Unpin for InputContent
impl UnsafeUnpin for InputContent
impl UnwindSafe for InputContent
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
Mutably borrows from an owned value. Read more