vc-runtime 0.1.0

Runtime backend for Visual Compiler
Documentation
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PromptResponse {
    pub prompt_id: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HistoryError {
    pub message: String,
    #[serde(default)]
    pub details: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ImageOutput {
    pub filename: String,
    pub subfolder: String,
    #[serde(rename = "type")]
    pub image_type: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct NodeOutput {
    pub images: Vec<ImageOutput>,
}

impl NodeOutput {
    pub fn has_images(&self) -> bool {
        !self.images.is_empty()
    }
}

pub type HistoryResponse = HashMap<String, HistoryEntry>;

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HistoryEntry {
    pub outputs: HashMap<String, NodeOutput>,
    #[serde(default)]
    pub error: Option<HistoryError>,
}

impl HistoryEntry {
    pub fn is_complete(&self) -> bool {
        self.outputs.values().any(|node| node.has_images())
    }
}