pub struct FunctionResponse {
pub name: String,
pub id: Option<String>,
pub response: Option<Value>,
pub parts: Vec<FunctionResponsePart>,
}Expand description
A response from a function
Fields§
§name: StringThe name of the function
id: Option<String>Unique identifier correlating this response with its FunctionCall.
Gemini 3.x models enforce strict response matching: every FunctionResponse
must echo the id from the corresponding FunctionCall, the name must match,
and the response count must equal the call count. Mismatches cause the model to
return empty responses with finish_reason: STOP. Earlier models ignore this field.
response: Option<Value>The response from the function This must be a valid JSON object
parts: Vec<FunctionResponsePart>Multimodal parts nested inside the functionResponse wire object.
Contains inlineData and/or fileData entries that accompany the JSON response.
Gemini 3 expects these inside the functionResponse, not as sibling Content parts.
Implementations§
Source§impl FunctionResponse
impl FunctionResponse
Sourcepub fn new(name: impl Into<String>, response: Value) -> Self
pub fn new(name: impl Into<String>, response: Value) -> Self
Create a new function response with a JSON value
Sourcepub fn with_id(self, id: impl Into<String>) -> Self
pub fn with_id(self, id: impl Into<String>) -> Self
Set the id correlating this response with its FunctionCall.
Required for Gemini 3.x strict response matching — pass the id from the
originating function call.
Sourcepub fn with_inline_data(
name: impl Into<String>,
response: Value,
inline_data: Vec<Blob>,
) -> Self
pub fn with_inline_data( name: impl Into<String>, response: Value, inline_data: Vec<Blob>, ) -> Self
Create with JSON response and inline data blobs.
Sourcepub fn with_file_data(
name: impl Into<String>,
response: Value,
file_data: Vec<FileDataRef>,
) -> Self
pub fn with_file_data( name: impl Into<String>, response: Value, file_data: Vec<FileDataRef>, ) -> Self
Create with JSON response and file data references.
Sourcepub fn inline_data_only(name: impl Into<String>, inline_data: Vec<Blob>) -> Self
pub fn inline_data_only(name: impl Into<String>, inline_data: Vec<Blob>) -> Self
Create with inline data only (no JSON response).
Sourcepub fn from_schema<Response>(
name: impl Into<String>,
response: Response,
) -> Result<Self, Error>where
Response: JsonSchema + Serialize,
pub fn from_schema<Response>(
name: impl Into<String>,
response: Response,
) -> Result<Self, Error>where
Response: JsonSchema + Serialize,
Create a new function response from a serializable type that will be parsed as JSON
Trait Implementations§
Source§impl Clone for FunctionResponse
impl Clone for FunctionResponse
Source§fn clone(&self) -> FunctionResponse
fn clone(&self) -> FunctionResponse
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more