liboxen 0.53.0

Oxen is a fast data version control system, built with machine learning training data in mind. Designed to handle terabytes of data with ease, using a workflow similar to git. Version both structured and unstructured data of any modality: text, images, video, audio, CSV, Parquet, JSONL, model checkpoints, and more. liboxen is the embeddable core library behind the oxen CLI and server, which power fine tuning and inference pipelines for multimodal LLMs, image models, and video models on Oxen.ai.
use serde::{Deserialize, Serialize};

// This are the minimum fields we need to check if an oxen response is valid
#[derive(Serialize, Deserialize, Debug)]
pub struct OxenResponse {
    pub status: String,
    pub status_message: String,
    pub status_description: Option<String>,
    pub error: Option<ErrorResponse>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ErrorResponse {
    title: String,
    #[serde(rename = "type")]
    error_type: String,
    detail: Option<String>,
}

impl OxenResponse {
    pub fn desc_or_msg(&self) -> String {
        match self.status_description.to_owned() {
            Some(desc) => desc,
            None => self.status_message.to_owned(),
        }
    }

    pub fn full_err_msg(&self) -> String {
        match self.error.to_owned() {
            Some(err) => format!("{}\n{}", err.title, err.detail.unwrap_or("".to_string())),
            None => self.desc_or_msg(),
        }
    }
}