openai-client-base 0.16.0

Auto-generated Rust client for the OpenAI API
/*
 * OpenAI API
 *
 * The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.
 *
 * The version of the OpenAPI document: 2.3.0
 *
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

/// LiveSessionClosed : Returned after the Live session finishes finalizing, with the close reason, final session snapshot, and cumulative audio usage. A connection closing without this event does not confirm successful finalization.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct LiveSessionClosed {
    /// The unique ID of the Live server event.
    #[serde(rename = "event_id")]
    pub event_id: String,
    /// The event_id of the client command associated with this server event, when supplied.
    #[serde(rename = "client_event_id", skip_serializing_if = "Option::is_none")]
    pub client_event_id: Option<String>,
    /// The event type, always `session.closed`.
    #[serde(rename = "type")]
    pub r#type: Type,
    #[serde(rename = "reason")]
    pub reason: Box<models::LiveSessionClosedReason>,
    #[serde(rename = "session")]
    pub session: Box<models::LiveSessionResourceParam>,
    #[serde(rename = "usage")]
    pub usage: Box<models::LiveSessionUsage>,
}

impl LiveSessionClosed {
    /// Returned after the Live session finishes finalizing, with the close reason, final session snapshot, and cumulative audio usage. A connection closing without this event does not confirm successful finalization.
    pub fn new(
        event_id: String,
        r#type: Type,
        reason: models::LiveSessionClosedReason,
        session: models::LiveSessionResourceParam,
        usage: models::LiveSessionUsage,
    ) -> LiveSessionClosed {
        LiveSessionClosed {
            event_id,
            client_event_id: None,
            r#type,
            reason: Box::new(reason),
            session: Box::new(session),
            usage: Box::new(usage),
        }
    }
}
/// The event type, always `session.closed`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "session.closed")]
    SessionClosed,
}

impl Default for Type {
    fn default() -> Type {
        Self::SessionClosed
    }
}

impl std::fmt::Display for LiveSessionClosed {
    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),
        }
    }
}