From d7472320a00fa0bfd6b9be904e0730461f093f61 Mon Sep 17 00:00:00 2001 From: 53hornet Date: Sat, 1 Jan 2022 12:27:41 -0500 Subject: chore: pre-ripping-apart --- src/models/mod.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/models') diff --git a/src/models/mod.rs b/src/models/mod.rs index a252f51..ddef71f 100644 --- a/src/models/mod.rs +++ b/src/models/mod.rs @@ -1,4 +1,21 @@ -use serde::{Deserialize, Serialize}; +use crate::error::TwinHError; +use bincode::deserialize; +use serde::{de::DeserializeOwned, Deserialize, Serialize}; +use sled::IVec; + +pub struct Entity { + pub umrn: u64, + pub model: M, +} + +impl Entity { + pub fn new(t: (IVec, IVec)) -> Result { + let (umrn, model) = t; + let umrn = deserialize(&umrn)?; + let model = deserialize(&model)?; + Ok(Entity { umrn, model }) + } +} #[derive(Serialize, Deserialize)] pub struct Part { @@ -12,7 +29,6 @@ pub struct Part { #[derive(Serialize, Deserialize)] pub struct Car { - pub key: u64, pub doors: u8, //pub engine: Engine, pub make: String, -- cgit v1.2.3