use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct RealtimeMcpToolCall {
#[serde(rename = "type")]
pub r#type: Type,
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "server_label")]
pub server_label: String,
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "arguments")]
pub arguments: String,
#[serde(
rename = "approval_request_id",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub approval_request_id: Option<Option<String>>,
#[serde(
rename = "output",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub output: Option<Option<String>>,
#[serde(
rename = "error",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub error: Option<Option<Box<models::RealtimeMcpToolCallError>>>,
}
impl RealtimeMcpToolCall {
pub fn new(
r#type: Type,
id: String,
server_label: String,
name: String,
arguments: String,
) -> RealtimeMcpToolCall {
RealtimeMcpToolCall {
r#type,
id,
server_label,
name,
arguments,
approval_request_id: None,
output: None,
error: None,
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "mcp_call")]
McpCall,
}
impl Default for Type {
fn default() -> Type {
Self::McpCall
}
}
impl std::fmt::Display for RealtimeMcpToolCall {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match serde_json::to_string(self) {
Ok(s) => write!(f, "{}", s),
Err(_) => Err(std::fmt::Error),
}
}
}