pub enum Part {
Thought {
text: String,
thought: bool,
},
Text {
text: String,
},
InlineData {
inline_data: Blob,
},
FunctionCall {
function_call: FunctionCall,
},
FunctionResponse {
function_response: FunctionResponse,
},
ExecutableCode {
executable_code: ExecutableCode,
},
CodeExecutionResult {
code_execution_result: CodeExecutionResult,
},
}Expand description
A single part of a Content message.
Parts are polymorphic — discriminated by field presence, not a type tag.
Deserialization reads the part’s fields once and picks the variant by the
same precedence #[serde(untagged)] uses (thought, text, inline data,
function call, function response, executable code, code execution result);
see the Deserialize impl below.
Variants§
Thought
A thought/reasoning part from the model (when includeThoughts is enabled).
Text
A text part.
InlineData
An inline data blob (audio, image, etc.).
FunctionCall
A function call from the model.
Fields
function_call: FunctionCallThe function call details.
FunctionResponse
A function response sent back to the model.
Fields
function_response: FunctionResponseThe function response details.
ExecutableCode
Executable code returned by the model.
Fields
executable_code: ExecutableCodeThe executable code details.
CodeExecutionResult
Result of code execution.
Fields
code_execution_result: CodeExecutionResultThe code execution result details.
Implementations§
Source§impl Part
impl Part
Sourcepub fn text(s: impl Into<String>) -> Self
pub fn text(s: impl Into<String>) -> Self
Create a text part.
§Examples
use gemini_genai_rs::protocol::types::Part;
let part = Part::text("Hello, world!");Sourcepub fn inline_data(
mime_type: impl Into<String>,
data: impl Into<String>,
) -> Self
pub fn inline_data( mime_type: impl Into<String>, data: impl Into<String>, ) -> Self
Create an inline data part (e.g. audio or image blob).
§Examples
use gemini_genai_rs::protocol::types::Part;
let audio = Part::inline_data("audio/pcm", "AQIDBA==");
let image = Part::inline_data("image/jpeg", "/9j/4AAQ...");Sourcepub fn function_call(call: FunctionCall) -> Self
pub fn function_call(call: FunctionCall) -> Self
Create a function call part.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Part
impl<'de> Deserialize<'de> for Part
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
One pass over the part’s fields.
#[serde(untagged)] buffered every part into an intermediate tree and
then tried each variant in turn, allocating an error for each miss; on
an audio part that meant copying the base64 payload twice and failing
twice before reaching InlineData. This reads the fields directly and
chooses the first variant whose fields are present, the same choice
untagged makes for any part the API sends. Unknown fields (such as
thoughtSignature) are ignored, as before.
impl StructuralPartialEq for Part
Auto Trait Implementations§
impl Freeze for Part
impl RefUnwindSafe for Part
impl Send for Part
impl Sync for Part
impl Unpin for Part
impl UnsafeUnpin for Part
impl UnwindSafe for Part
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>,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].