comfyui_api/models/
history.rs1use std::collections::HashMap;
2
3use serde::{Deserialize, Serialize};
4
5use super::{Image, Prompt};
6
7#[derive(Deserialize, Debug)]
9#[serde(transparent)]
10pub struct History {
11 pub tasks: HashMap<uuid::Uuid, Task>,
13}
14
15#[derive(Serialize, Deserialize, Debug)]
17pub struct Task {
18 pub outputs: Outputs,
20 pub prompt: PromptResult,
22}
23
24#[derive(Serialize, Deserialize, Debug)]
26#[serde(transparent)]
27pub struct Outputs {
28 pub nodes: HashMap<String, NodeOutputOrUnknown>,
30}
31
32#[derive(Serialize, Deserialize, Debug)]
34#[serde(untagged)]
35pub enum NodeOutputOrUnknown {
36 NodeOutput(NodeOutput),
38 Unknown(serde_json::Value),
40}
41
42#[derive(Serialize, Deserialize, Debug)]
44pub struct NodeOutput {
45 pub images: Vec<Image>,
47}
48
49#[derive(Serialize, Deserialize, Debug)]
51#[serde(from = "(u64, uuid::Uuid, Prompt, ExtraData, OutputsToExecute)")]
52pub struct PromptResult {
53 pub num: u64,
55 pub id: uuid::Uuid,
57 pub prompt: Prompt,
59 pub extra_data: ExtraData,
61 pub outputs_to_execute: OutputsToExecute,
63}
64
65impl From<(u64, uuid::Uuid, Prompt, ExtraData, OutputsToExecute)> for PromptResult {
66 fn from(
67 (num, id, prompt, extra_data, outputs_to_execute): (
68 u64,
69 uuid::Uuid,
70 Prompt,
71 ExtraData,
72 OutputsToExecute,
73 ),
74 ) -> Self {
75 Self {
76 num,
77 id,
78 prompt,
79 extra_data,
80 outputs_to_execute,
81 }
82 }
83}
84
85impl From<PromptResult> for (u64, uuid::Uuid, Prompt, ExtraData, OutputsToExecute) {
86 fn from(
87 PromptResult {
88 num,
89 id,
90 prompt,
91 extra_data,
92 outputs_to_execute,
93 }: PromptResult,
94 ) -> Self {
95 (num, id, prompt, extra_data, outputs_to_execute)
96 }
97}
98
99#[derive(Serialize, Deserialize, Debug, Clone)]
101pub struct ExtraData {
102 pub client_id: uuid::Uuid,
104}
105
106#[derive(Serialize, Deserialize, Debug, Clone)]
108#[serde(transparent)]
109pub struct OutputsToExecute {
110 pub nodes: Vec<String>,
112}