diff --git a/Cargo.lock b/Cargo.lock index 23110119..7bf56363 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2098,6 +2098,15 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "modeling-module" +version = "0.1.0" +dependencies = [ + "module", + "serde", + "uuid", +] + [[package]] name = "module" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index d7f0a99e..8318ab62 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,5 +10,6 @@ members = [ "crates/cadara", "crates/module", "crates/workspace", + "crates/modeling-module", ] resolver = "2" diff --git a/crates/modeling-module/Cargo.toml b/crates/modeling-module/Cargo.toml new file mode 100644 index 00000000..4693c47e --- /dev/null +++ b/crates/modeling-module/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "modeling-module" +version = "0.1.0" +edition = "2021" +license = "AGPL-3.0-only" +publish = false + +[dependencies] +module = { path = "../module" } +uuid = { version = "1.6.1", features = ["v4", "serde"] } +serde = { version = "1.0.195", features = ["derive", "alloc", "rc"] } diff --git a/crates/modeling-module/src/lib.rs b/crates/modeling-module/src/lib.rs new file mode 100644 index 00000000..82b5dd9c --- /dev/null +++ b/crates/modeling-module/src/lib.rs @@ -0,0 +1,57 @@ +#![warn(clippy::nursery)] +#![warn(clippy::pedantic)] +#![allow(clippy::module_name_repetitions)] +#![allow(clippy::cognitive_complexity)] + +use module::{DataTransaction, Module, ReversibleDataTransaction}; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Default)] +pub struct ModelingModule {} + +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +pub struct DataSection {} + +impl DataTransaction for DataSection { + type Args = (); + + type Error = (); + + type Output = (); + + fn apply(&mut self, _args: Self::Args) -> Result { + Ok(()) + } + + fn undo_history_name(_args: &Self::Args) -> String { + "nothing".to_string() + } +} + +impl ReversibleDataTransaction for DataSection { + type UndoData = (); + + fn apply(&mut self, _args: Self::Args) -> Result<(Self::Output, Self::UndoData), Self::Error> { + Ok(((), ())) + } + + fn undo(&mut self, _undo_data: Self::UndoData) {} +} + +impl Module for ModelingModule { + type PersistentData = DataSection; + + type PersistentUserData = DataSection; + + type SessionData = DataSection; + + type SharedData = DataSection; + + fn name() -> String { + "Modeling".to_string() + } + + fn uuid() -> uuid::Uuid { + uuid::Uuid::parse_str("04d338d9-b7a9-4f5a-b04d-724466f4058f").expect("static UUID") + } +}