use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct BetaPromptCacheMissDiagnosticsBody {
#[serde(rename = "type")]
pub r#type: Type,
#[serde(rename = "reason")]
pub reason: models::BetaCacheMissReasonTypeEnum,
#[serde(rename = "cache_missed_tokens")]
pub cache_missed_tokens: i32,
#[serde(
rename = "comparison_reusable_tokens",
skip_serializing_if = "Option::is_none"
)]
pub comparison_reusable_tokens: Option<i32>,
}
impl BetaPromptCacheMissDiagnosticsBody {
pub fn new(
r#type: Type,
reason: models::BetaCacheMissReasonTypeEnum,
cache_missed_tokens: i32,
) -> BetaPromptCacheMissDiagnosticsBody {
BetaPromptCacheMissDiagnosticsBody {
r#type,
reason,
cache_missed_tokens,
comparison_reusable_tokens: None,
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "cache_miss")]
CacheMiss,
}
impl Default for Type {
fn default() -> Type {
Self::CacheMiss
}
}
impl std::fmt::Display for BetaPromptCacheMissDiagnosticsBody {
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),
}
}
}