notebook_types/v0/
diagram_judgment.rs

1use serde::{Deserialize, Serialize};
2use tsify::Tsify;
3use uuid::Uuid;
4
5use super::model::{Mor, Ob};
6use super::theory::{MorType, ObType};
7
8/// Declares an object of a diagram in a model.
9#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Tsify)]
10#[tsify(into_wasm_abi, from_wasm_abi, missing_as_null)]
11pub struct DiagramObDecl {
12    /// Human-readable name of object.
13    pub name: String,
14
15    /// Globally unique identifier of object.
16    pub id: Uuid,
17
18    /// The object's type in the double theory.
19    #[serde(rename = "obType")]
20    pub ob_type: ObType,
21
22    /// Object in the model that this object is over, if defined.
23    pub over: Option<Ob>,
24}
25
26/// Declares a morphism of a diagram in a model.
27#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Tsify)]
28#[tsify(into_wasm_abi, from_wasm_abi, missing_as_null)]
29pub struct DiagramMorDecl {
30    /// Human-readable name of morphism.
31    pub name: String,
32
33    /// Globally unique identifier of morphism.
34    pub id: Uuid,
35
36    /// The morphism's type in the double theory.
37    #[serde(rename = "morType")]
38    pub mor_type: MorType,
39
40    /// Morphism in the model that this morphism is over, if defined.
41    pub over: Option<Mor>,
42
43    /// Domain of this morphism, if defined.
44    pub dom: Option<Ob>,
45
46    /// Codomain of this morphism, if defined.
47    pub cod: Option<Ob>,
48}
49
50/// A judgment in the definition of a diagram in a model.
51#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Tsify)]
52#[serde(tag = "tag")]
53#[tsify(into_wasm_abi, from_wasm_abi)]
54pub enum DiagramJudgment {
55    #[serde(rename = "object")]
56    Object(DiagramObDecl),
57    #[serde(rename = "morphism")]
58    Morphism(DiagramMorDecl),
59}