Struct Content
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§
§impl Content
impl Content
pub fn user(text: impl Into<String>) -> Content
pub fn user(text: impl Into<String>) -> Content
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);pub fn model(text: impl Into<String>) -> Content
pub fn model(text: impl Into<String>) -> Content
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));pub fn function_response(name: impl Into<String>, response: Value) -> Content
pub fn function_response(name: impl Into<String>, response: Value) -> Content
Create a user-role content with a single function response part.
pub fn from_parts(role: Role, parts: Vec<Part>) -> Content
pub fn from_parts(role: Role, parts: Vec<Part>) -> Content
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§
§impl<'de> Deserialize<'de> for Content
impl<'de> Deserialize<'de> for Content
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Content, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Content, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl Serialize for Content
impl Serialize for Content
§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 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