diff --git a/01.workspace/heave/src/lib.rs b/01.workspace/heave/src/lib.rs index 89aee4f..e5e9007 100644 --- a/01.workspace/heave/src/lib.rs +++ b/01.workspace/heave/src/lib.rs @@ -8,9 +8,12 @@ mod trt; mod tst; pub use crate::str::attribute::O as Attribute; +pub use crate::str::catalog::O as Catalog; pub use crate::str::entity::O as Entity; pub use crate::str::value::E as Value; pub use crate::trt::eav::T as EAV; pub use crate::trt::from_eav::T as FromEAV; pub use crate::trt::to_eav::T as ToEAV; pub use crate::trt::to_value::T as ToValue; + +pub mod sqlite {} diff --git a/01.workspace/heave/src/str/catalog.rs b/01.workspace/heave/src/str/catalog.rs new file mode 100644 index 0000000..4b9e628 --- /dev/null +++ b/01.workspace/heave/src/str/catalog.rs @@ -0,0 +1,31 @@ +use crate::*; + +#[derive(Debug, Default, PartialEq, Clone)] +pub struct O { + path: String, + items: std::collections::HashMap, +} + +impl O { + pub fn new(path: &str) -> Self { + Self { + path: String::from(path), + ..O::default() + } + } + pub fn persist(&mut self, entity: &mut Entity) { + self.items.insert(entity.id.clone(), entity.clone()); + entity.persisted = true; + } +} + +// impl std::fmt::Display for O { +// fn fmt(&self, _f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { +// todo!(); +// } +// } + +// #[cfg(test)] +// mod unit_tests { +// use super::*; +// } diff --git a/01.workspace/heave/src/str/entity.rs b/01.workspace/heave/src/str/entity.rs index 3874934..6038eb5 100644 --- a/01.workspace/heave/src/str/entity.rs +++ b/01.workspace/heave/src/str/entity.rs @@ -59,10 +59,4 @@ impl O { let value = self.value_of(id).unwrap(); T::from(value.clone()) } - pub fn persist(&self) { - todo!() - } - pub fn load(_id: &str) -> Self { - todo!() - } } diff --git a/01.workspace/heave/src/str/mod.rs b/01.workspace/heave/src/str/mod.rs index dd1e5a1..d11628e 100644 --- a/01.workspace/heave/src/str/mod.rs +++ b/01.workspace/heave/src/str/mod.rs @@ -1,3 +1,4 @@ pub mod attribute; +pub mod catalog; pub mod entity; pub mod value; diff --git a/01.workspace/heave/src/tst/intended_use.rs b/01.workspace/heave/src/tst/intended_use.rs index 671a5ff..9c0c35f 100644 --- a/01.workspace/heave/src/tst/intended_use.rs +++ b/01.workspace/heave/src/tst/intended_use.rs @@ -122,4 +122,15 @@ mod tests { let converted_product = Product::from_eav(entity); assert_eq!(expected_product, converted_product); } + #[test] + fn check_007() { + let mut catalog = Catalog::new(""); + let product = Product { + id: short_uuid::short!().to_string(), + name: "laptop".to_string(), + price: 200000u64, + }; + let mut entity = product.to_eav(); + catalog.persist(&mut entity); + } }