pub struct Content {
pub role: Option<Role>,
pub parts: Vec<Part>,
}Expand description
A content message containing a role and a sequence of parts.
Fields§
§role: Option<Role>Role of the content author (User, Model, or System).
parts: Vec<Part>Ordered parts that compose this content.
Implementations§
Source§impl Content
impl Content
Sourcepub fn user(text: impl Into<String>) -> Self
pub fn user(text: impl Into<String>) -> Self
Create a user-role content with a single text part.
§Examples
use gemini_genai_rs::protocol::types::{Content, Role};
let msg = Content::user("What is the weather?");
assert_eq!(msg.role, Some(Role::User));
assert_eq!(msg.parts.len(), 1);Sourcepub fn model(text: impl Into<String>) -> Self
pub fn model(text: impl Into<String>) -> Self
Create a model-role content with a single text part.
§Examples
use gemini_genai_rs::protocol::types::{Content, Role};
let msg = Content::model("The weather is sunny.");
assert_eq!(msg.role, Some(Role::Model));Sourcepub fn function_response(name: impl Into<String>, response: Value) -> Self
pub fn function_response(name: impl Into<String>, response: Value) -> Self
Create a user-role content with a single function response part.
Sourcepub fn from_parts(role: Role, parts: Vec<Part>) -> Self
pub fn from_parts(role: Role, parts: Vec<Part>) -> Self
Create a content from an explicit role and parts list.
§Examples
use gemini_genai_rs::protocol::types::{Content, Part, Role};
let parts = vec![
Part::text("Hello"),
Part::inline_data("audio/pcm", "AQID"),
];
let msg = Content::from_parts(Role::User, parts);
assert_eq!(msg.parts.len(), 2);Trait Implementations§
Source§impl<'de> Deserialize<'de> for Content
impl<'de> Deserialize<'de> for Content
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>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Content
Auto Trait Implementations§
impl Freeze for Content
impl RefUnwindSafe for Content
impl Send for Content
impl Sync for Content
impl Unpin for Content
impl UnwindSafe for Content
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