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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user