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

/// MessageContentImageFileObject : References an image [File](/docs/api-reference/files) in the content of a message.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct MessageContentImageFileObject {
    /// Always `image_file`.
    #[serde(rename = "type")]
    pub r#type: Type,
    #[serde(rename = "image_file")]
    pub image_file: Box<models::MessageContentImageFileObjectImageFile>,
}

impl MessageContentImageFileObject {
    /// References an image [File](/docs/api-reference/files) in the content of a message.
    pub fn new(
        r#type: Type,
        image_file: models::MessageContentImageFileObjectImageFile,
    ) -> MessageContentImageFileObject {
        MessageContentImageFileObject {
            r#type,
            image_file: Box::new(image_file),
        }
    }
}
/// Always `image_file`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "image_file")]
    ImageFile,
}

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

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