diff --git a/src/document.rs b/src/document.rs index 5640e82..c74e29c 100644 --- a/src/document.rs +++ b/src/document.rs @@ -5,7 +5,7 @@ mod field; mod record; mod session; -use record::InternalRecords; +use record::{InternalRecord, InternalRecords}; pub use clock::Clock; pub use create::CreateDoc; diff --git a/src/document/create.rs b/src/document/create.rs index 702fa0b..cdf3ead 100644 --- a/src/document/create.rs +++ b/src/document/create.rs @@ -1,11 +1,11 @@ -use super::InternalRecords; +use super::{InternalRecord, InternalRecords}; use crate::{ action::{Action, CalcValue, Calculation, MsgAction, Query, Records}, document::{ definition::{DocDef, DocFuncType}, field::Field, }, - message::wrapper::{InternalRecord, Message, Oid, Reply, Update}, + message::wrapper::{Message, Oid, Reply, Update}, mtterror::{ErrorID, MTTError}, name::NameType, queue::{ diff --git a/src/document/record.rs b/src/document/record.rs index 90f1abe..c0f947a 100644 --- a/src/document/record.rs +++ b/src/document/record.rs @@ -1,10 +1,42 @@ use crate::{ action::Field, - message::wrapper::{InternalRecord, Oid}, + message::wrapper::Oid, mtterror::{ErrorID, MTTError}, name::{Name, NameType, Names}, }; use std::collections::HashMap; +use uuid::Uuid; + +#[derive(Clone, Debug)] +pub struct InternalRecord { + data: HashMap, +} + +impl InternalRecord { + pub fn new() -> Self { + Self { + data: HashMap::new(), + } + } + + pub fn insert(&mut self, id: Uuid, data: F) -> Field + where + F: Into, + { + match self.data.insert(id, data.into()) { + Some(data) => data.clone(), + None => Field::None, + } + } + + pub fn get(&self, id: &Uuid) -> Option<&Field> { + self.data.get(id) + } + + pub fn is_empty(&self) -> bool { + self.data.is_empty() + } +} #[derive(Clone, Debug)] pub struct InternalRecords { diff --git a/src/message/wrapper.rs b/src/message/wrapper.rs index 6ba4ab6..f746c99 100644 --- a/src/message/wrapper.rs +++ b/src/message/wrapper.rs @@ -365,37 +365,6 @@ mod replies { } } -#[derive(Clone, Debug)] -pub struct InternalRecord { - data: HashMap, -} - -impl InternalRecord { - pub fn new() -> Self { - Self { - data: HashMap::new(), - } - } - - pub fn insert(&mut self, id: Uuid, data: F) -> Field - where - F: Into, - { - match self.data.insert(id, data.into()) { - Some(data) => data.clone(), - None => Field::None, - } - } - - pub fn get(&self, id: &Uuid) -> Option<&Field> { - self.data.get(id) - } - - pub fn is_empty(&self) -> bool { - self.data.is_empty() - } -} - #[derive(Clone, Debug)] pub struct Document { data: HashMap,