Moved InternalRecord into document module.
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s
This commit is contained in:
parent
4f69ecc7a9
commit
45bcd04ee3
@ -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;
|
||||
|
||||
@ -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::{
|
||||
|
||||
@ -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<Uuid, Field>,
|
||||
}
|
||||
|
||||
impl InternalRecord {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
data: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn insert<F>(&mut self, id: Uuid, data: F) -> Field
|
||||
where
|
||||
F: Into<Field>,
|
||||
{
|
||||
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 {
|
||||
|
||||
@ -365,37 +365,6 @@ mod replies {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct InternalRecord {
|
||||
data: HashMap<Uuid, Field>,
|
||||
}
|
||||
|
||||
impl InternalRecord {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
data: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn insert<F>(&mut self, id: Uuid, data: F) -> Field
|
||||
where
|
||||
F: Into<Field>,
|
||||
{
|
||||
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<NameType, CalcValue>,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user