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};

/// LiveLiveError : Details of an error encountered by the Live session, including the affected parameter or client command when available.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct LiveLiveError {
    /// The category of error, such as `invalid_request_error` for an invalid Live client command.
    #[serde(rename = "type")]
    pub r#type: String,
    /// A machine-readable code identifying the Live error, such as `unknown_parameter`.
    #[serde(rename = "code")]
    pub code: String,
    /// A human-readable explanation of the Live error.
    #[serde(rename = "message")]
    pub message: String,
    /// The parameter that caused the error, when applicable, such as `session.voice`.
    #[serde(rename = "param", skip_serializing_if = "Option::is_none")]
    pub param: Option<String>,
    /// The event_id of the client command that caused the error, when supplied.
    #[serde(rename = "client_event_id", skip_serializing_if = "Option::is_none")]
    pub client_event_id: Option<String>,
}

impl LiveLiveError {
    /// Details of an error encountered by the Live session, including the affected parameter or client command when available.
    pub fn new(r#type: String, code: String, message: String) -> LiveLiveError {
        LiveLiveError {
            r#type,
            code,
            message,
            param: None,
            client_event_id: None,
        }
    }
}

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