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

/// LiveCreateResponse : The created Live session identifier and WebRTC answer. Apply transport.sdp as the peer's remote answer and wait for session.started on the data channel before sending commands.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct LiveCreateResponse {
    #[serde(rename = "session")]
    pub session: Box<models::LiveCreateResponseSession>,
    #[serde(rename = "transport")]
    pub transport: models::LiveWebRtcTransport,
}

impl LiveCreateResponse {
    /// The created Live session identifier and WebRTC answer. Apply transport.sdp as the peer's remote answer and wait for session.started on the data channel before sending commands.
    pub fn new(
        session: models::LiveCreateResponseSession,
        transport: models::LiveWebRtcTransport,
    ) -> LiveCreateResponse {
        LiveCreateResponse {
            session: Box::new(session),
            transport,
        }
    }
}

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