catlog_wasm/
model_diagram_presentation.rs

1//! Serialization of elaborated diagrams.
2
3use serde::{Deserialize, Serialize};
4use tsify::Tsify;
5
6use catlog::zero::{QualifiedLabel, QualifiedName};
7use notebook_types::current::{Mor, MorType, Ob, ObType};
8
9/// Presentation of a free diagram in a model.
10#[derive(Serialize, Deserialize, Tsify)]
11#[tsify(into_wasm_abi, from_wasm_abi)]
12pub struct ModelDiagramPresentation {
13    /// Generating objects.
14    #[serde(rename = "obGenerators")]
15    pub ob_generators: Vec<DiagramObGenerator>,
16
17    /// Generating morphisms.
18    #[serde(rename = "morGenerators")]
19    pub mor_generators: Vec<DiagramMorGenerator>,
20}
21
22/// Object generator in a diagram in a model.
23#[derive(Serialize, Deserialize, Tsify)]
24#[tsify(into_wasm_abi, from_wasm_abi)]
25pub struct DiagramObGenerator {
26    /// Unique identifier of object.
27    pub id: QualifiedName,
28
29    /// Human-readable label for object.
30    pub label: Option<QualifiedLabel>,
31
32    /// The object's type in the double theory.
33    #[serde(rename = "obType")]
34    pub ob_type: ObType,
35
36    /// Object in the model that this object is over.
37    pub over: Ob,
38}
39
40/// Morphism generator in a diagram in a model.
41#[derive(Serialize, Deserialize, Tsify)]
42#[tsify(into_wasm_abi, from_wasm_abi)]
43pub struct DiagramMorGenerator {
44    /// Unique identifier of morphism.
45    pub id: QualifiedName,
46
47    /// The morphism's type in the double theory.
48    #[serde(rename = "morType")]
49    pub mor_type: MorType,
50
51    /// Morphism in the model that this morphism is over.
52    pub over: Mor,
53
54    /// Domain of this morphism.
55    pub dom: Ob,
56
57    /// Codomain of this morphism.
58    pub cod: Ob,
59}