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

/// ImageGenToolCall : An image generation request made by the model.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct ImageGenToolCall {
    /// The type of the image generation call. Always `image_generation_call`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The unique ID of the image generation call.
    #[serde(rename = "id")]
    pub id: String,
    /// The status of the image generation call.
    #[serde(rename = "status")]
    pub status: Status,
    /// The generated image encoded in base64.
    #[serde(rename = "result", deserialize_with = "Option::deserialize")]
    pub result: Option<String>,
}

impl ImageGenToolCall {
    /// An image generation request made by the model.
    pub fn new(
        r#type: Type,
        id: String,
        status: Status,
        result: Option<String>,
    ) -> ImageGenToolCall {
        ImageGenToolCall {
            r#type,
            id,
            status,
            result,
        }
    }
}
/// The type of the image generation call. Always `image_generation_call`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "image_generation_call")]
    ImageGenerationCall,
}

impl Default for Type {
    fn default() -> Type {
        Self::ImageGenerationCall
    }
}
/// The status of the image generation call.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
    #[serde(rename = "in_progress")]
    InProgress,
    #[serde(rename = "completed")]
    Completed,
    #[serde(rename = "generating")]
    Generating,
    #[serde(rename = "failed")]
    Failed,
}

impl Default for Status {
    fn default() -> Status {
        Self::InProgress
    }
}

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