Skip to content

Commit

Permalink
feat: add minimal modeling-module
Browse files Browse the repository at this point in the history
This is also a place holder for now, but will later be expanded to allow
3D modeling.
  • Loading branch information
maximmaxim345 committed Sep 9, 2024
1 parent 9578159 commit e815b34
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ members = [
"crates/cadara",
"crates/module",
"crates/workspace",
"crates/modeling-module",
]
resolver = "2"
11 changes: 11 additions & 0 deletions crates/modeling-module/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"] }
57 changes: 57 additions & 0 deletions crates/modeling-module/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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<Self::Output, Self::Error> {
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")
}
}

0 comments on commit e815b34

Please sign in to comment.