catlog_wasm/
model_presentation.rs

1//! Serialization of elaborated models.
2//!
3//! In contrast to a [model
4//! notebook](notebook_types::current::ModelDocumentContent), which is mere
5//! *notation*, these data types serialize a fully *elaborated* model. The
6//! serialization is as a presentation in terms of generators and relations.
7
8use serde::{Deserialize, Serialize};
9use tsify::Tsify;
10
11use catlog::zero::{QualifiedLabel, QualifiedName};
12use notebook_types::current::{MorType, Ob, ObType};
13
14/// Presentation of a model of a double theory.
15///
16/// TODO: Include equations between morphisms.
17#[derive(Serialize, Deserialize, Tsify)]
18#[tsify(into_wasm_abi, from_wasm_abi)]
19pub struct ModelPresentation {
20    /// Generating objects.
21    #[serde(rename = "obGenerators")]
22    pub ob_generators: Vec<ObGenerator>,
23
24    /// Generating morphisms.
25    #[serde(rename = "morGenerators")]
26    pub mor_generators: Vec<MorGenerator>,
27}
28
29/// Object generator in a model of a double theory.
30#[derive(Serialize, Deserialize, Tsify)]
31#[tsify(into_wasm_abi, from_wasm_abi)]
32pub struct ObGenerator {
33    /// Unique identifier of object.
34    pub id: QualifiedName,
35
36    /// Human-readable label for object.
37    pub label: Option<QualifiedLabel>,
38
39    /// The object's type in the double theory.
40    #[serde(rename = "obType")]
41    pub ob_type: ObType,
42}
43
44/// Morphism generator in a model of a double theory.
45#[derive(Serialize, Deserialize, Tsify)]
46#[tsify(into_wasm_abi, from_wasm_abi)]
47pub struct MorGenerator {
48    /// Unique identifier of morphism.
49    pub id: QualifiedName,
50
51    /// Human-readable label for morphism.
52    pub label: Option<QualifiedLabel>,
53
54    /// The morphism's type in the double theory.
55    #[serde(rename = "morType")]
56    pub mor_type: MorType,
57
58    /// Domain of morphism.
59    pub dom: Ob,
60
61    /// Codomain of morphism.
62    pub cod: Ob,
63}