openai-client-base 0.12.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};

/// ChatSessionFileUpload : Upload permissions and limits applied to the session.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct ChatSessionFileUpload {
    /// Indicates if uploads are enabled for the session.
    #[serde(rename = "enabled")]
    pub enabled: bool,
    /// Maximum upload size in megabytes.
    #[serde(rename = "max_file_size", deserialize_with = "Option::deserialize")]
    pub max_file_size: Option<i32>,
    /// Maximum number of uploads allowed during the session.
    #[serde(rename = "max_files", deserialize_with = "Option::deserialize")]
    pub max_files: Option<i32>,
}

impl ChatSessionFileUpload {
    /// Upload permissions and limits applied to the session.
    pub fn new(
        enabled: bool,
        max_file_size: Option<i32>,
        max_files: Option<i32>,
    ) -> ChatSessionFileUpload {
        ChatSessionFileUpload {
            enabled,
            max_file_size,
            max_files,
        }
    }
}

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