Moved InternalRecords into document module.
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 2s
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 2s
This commit is contained in:
parent
920c2da38f
commit
4f69ecc7a9
@ -5,6 +5,8 @@ mod field;
|
|||||||
mod record;
|
mod record;
|
||||||
mod session;
|
mod session;
|
||||||
|
|
||||||
|
use record::InternalRecords;
|
||||||
|
|
||||||
pub use clock::Clock;
|
pub use clock::Clock;
|
||||||
pub use create::CreateDoc;
|
pub use create::CreateDoc;
|
||||||
pub use definition::DocDef;
|
pub use definition::DocDef;
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
|
use super::InternalRecords;
|
||||||
use crate::{
|
use crate::{
|
||||||
action::{Action, CalcValue, Calculation, MsgAction, Query, Records},
|
action::{Action, CalcValue, Calculation, MsgAction, Query, Records},
|
||||||
document::{
|
document::{
|
||||||
definition::{DocDef, DocFuncType},
|
definition::{DocDef, DocFuncType},
|
||||||
field::Field,
|
field::Field,
|
||||||
},
|
},
|
||||||
message::wrapper::{InternalRecord, InternalRecords, Message, Oid, Reply, Update},
|
message::wrapper::{InternalRecord, Message, Oid, Reply, Update},
|
||||||
mtterror::{ErrorID, MTTError},
|
mtterror::{ErrorID, MTTError},
|
||||||
name::NameType,
|
name::NameType,
|
||||||
queue::{
|
queue::{
|
||||||
|
|||||||
@ -1,9 +1,55 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
action::Field,
|
action::Field,
|
||||||
message::wrapper::{InternalRecord, InternalRecords, Oid},
|
message::wrapper::{InternalRecord, Oid},
|
||||||
mtterror::{ErrorID, MTTError},
|
mtterror::{ErrorID, MTTError},
|
||||||
name::{Name, NameType, Names},
|
name::{Name, NameType, Names},
|
||||||
};
|
};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct InternalRecords {
|
||||||
|
data: HashMap<Oid, InternalRecord>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl InternalRecords {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
data: HashMap::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn insert(&mut self, oid: Oid, record: InternalRecord) -> Option<InternalRecord> {
|
||||||
|
self.data.insert(oid, record)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get(&self, oid: &Oid) -> Option<&InternalRecord> {
|
||||||
|
self.data.get(oid)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn remove(&mut self, oid: &Oid) -> Option<InternalRecord> {
|
||||||
|
self.data.remove(oid)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn iter(&self) -> impl Iterator<Item = (&Oid, &InternalRecord)> {
|
||||||
|
self.data.iter()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn keys(&self) -> impl Iterator<Item = &Oid> {
|
||||||
|
self.data.keys()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn values(&self) -> impl Iterator<Item = &InternalRecord> {
|
||||||
|
self.data.values()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn contains_key(&self, oid: &Oid) -> bool {
|
||||||
|
self.data.contains_key(oid)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn len(&self) -> usize {
|
||||||
|
self.data.len()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Record {
|
pub struct Record {
|
||||||
|
|||||||
@ -396,53 +396,6 @@ impl InternalRecord {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct InternalRecords {
|
|
||||||
data: HashMap<Oid, InternalRecord>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl InternalRecords {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Self {
|
|
||||||
data: HashMap::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn insert(&mut self, oid: Oid, record: InternalRecord) -> Option<InternalRecord> {
|
|
||||||
self.data.insert(oid, record)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get(&self, oid: &Oid) -> Option<&InternalRecord> {
|
|
||||||
self.data.get(oid)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn remove(&mut self, oid: &Oid) -> Option<InternalRecord> {
|
|
||||||
self.data.remove(oid)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iter(&self) -> impl Iterator<Item = (&Oid, &InternalRecord)> {
|
|
||||||
self.data.iter()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn keys(&self) -> impl Iterator<Item = &Oid> {
|
|
||||||
self.data.keys()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn values(&self) -> impl Iterator<Item = &InternalRecord> {
|
|
||||||
self.data.values()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn contains_key(&self, oid: &Oid) -> bool {
|
|
||||||
self.data.contains_key(oid)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn len(&self) -> usize {
|
|
||||||
self.data.len()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Document {
|
pub struct Document {
|
||||||
data: HashMap<NameType, CalcValue>,
|
data: HashMap<NameType, CalcValue>,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user