Moved Oid 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
45bcd04ee3
commit
115910120c
@ -5,7 +5,7 @@ mod field;
|
|||||||
mod record;
|
mod record;
|
||||||
mod session;
|
mod session;
|
||||||
|
|
||||||
use record::{InternalRecord, InternalRecords};
|
use record::{InternalRecord, InternalRecords, Oid};
|
||||||
|
|
||||||
pub use clock::Clock;
|
pub use clock::Clock;
|
||||||
pub use create::CreateDoc;
|
pub use create::CreateDoc;
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
use super::{InternalRecord, InternalRecords};
|
use super::{InternalRecord, InternalRecords, Oid};
|
||||||
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::{Message, Oid, Reply, Update},
|
message::wrapper::{Message, Reply, Update},
|
||||||
mtterror::{ErrorID, MTTError},
|
mtterror::{ErrorID, MTTError},
|
||||||
name::NameType,
|
name::NameType,
|
||||||
queue::{
|
queue::{
|
||||||
|
|||||||
@ -1,12 +1,40 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
action::Field,
|
action::Field,
|
||||||
message::wrapper::Oid,
|
|
||||||
mtterror::{ErrorID, MTTError},
|
mtterror::{ErrorID, MTTError},
|
||||||
name::{Name, NameType, Names},
|
name::{Name, NameType, Names},
|
||||||
};
|
};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
||||||
|
pub struct Oid {
|
||||||
|
oid: Uuid,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Oid {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
oid: Uuid::new_v4(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod oids {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn are_oids_random() {
|
||||||
|
let count = 10;
|
||||||
|
let mut holder: Vec<Oid> = Vec::new();
|
||||||
|
while holder.len() < count {
|
||||||
|
let result = Oid::new();
|
||||||
|
assert!(!holder.contains(&result));
|
||||||
|
holder.push(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct InternalRecord {
|
pub struct InternalRecord {
|
||||||
data: HashMap<Uuid, Field>,
|
data: HashMap<Uuid, Field>,
|
||||||
|
|||||||
@ -266,24 +266,6 @@ impl Operation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
enum QueryType {
|
|
||||||
Query(Query),
|
|
||||||
Oids(HashSet<Oid>),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Query> for QueryType {
|
|
||||||
fn from(value: Query) -> Self {
|
|
||||||
QueryType::Query(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<HashSet<Oid>> for QueryType {
|
|
||||||
fn from(value: HashSet<Oid>) -> Self {
|
|
||||||
QueryType::Oids(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
@ -490,32 +472,3 @@ impl Update {
|
|||||||
&mut self.values
|
&mut self.values
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
|
||||||
pub struct Oid {
|
|
||||||
oid: Uuid,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Oid {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Self {
|
|
||||||
oid: Uuid::new_v4(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod oids {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn are_oids_random() {
|
|
||||||
let count = 10;
|
|
||||||
let mut holder: Vec<Oid> = Vec::new();
|
|
||||||
while holder.len() < count {
|
|
||||||
let result = Oid::new();
|
|
||||||
assert!(!holder.contains(&result));
|
|
||||||
holder.push(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user