openai-client-base 0.8.1

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

/// BatchRequestOutput : The per-line object of the batch output and error files
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct BatchRequestOutput {
    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,
    /// A developer-provided per-request id that will be used to match outputs to inputs.
    #[serde(rename = "custom_id", skip_serializing_if = "Option::is_none")]
    pub custom_id: Option<String>,
    #[serde(
        rename = "response",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub response: Option<Option<Box<models::BatchRequestOutputResponse>>>,
    #[serde(
        rename = "error",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub error: Option<Option<Box<models::BatchRequestOutputError>>>,
}

impl BatchRequestOutput {
    /// The per-line object of the batch output and error files
    pub fn new() -> BatchRequestOutput {
        BatchRequestOutput {
            id: None,
            custom_id: None,
            response: None,
            error: None,
        }
    }
}

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