Use cleaner CRDT data types for objects to avoid accidents like #16 #18
2 changed files with 4 additions and 6 deletions
|
@ -39,11 +39,10 @@ impl CRDT for BucketState {
|
||||||
|
|
||||||
impl Bucket {
|
impl Bucket {
|
||||||
pub fn new(name: String) -> Self {
|
pub fn new(name: String) -> Self {
|
||||||
let ret = Bucket {
|
Bucket {
|
||||||
name,
|
name,
|
||||||
state: crdt::LWW::new(BucketState::Present(crdt::LWWMap::new())),
|
state: crdt::LWW::new(BucketState::Present(crdt::LWWMap::new())),
|
||||||
};
|
}
|
||||||
ret
|
|
||||||
}
|
}
|
||||||
pub fn is_deleted(&self) -> bool {
|
pub fn is_deleted(&self) -> bool {
|
||||||
*self.state.get() == BucketState::Deleted
|
*self.state.get() == BucketState::Deleted
|
||||||
|
|
|
@ -31,14 +31,13 @@ impl Key {
|
||||||
pub fn new(name: String) -> Self {
|
pub fn new(name: String) -> Self {
|
||||||
let key_id = format!("GK{}", hex::encode(&rand::random::<[u8; 12]>()[..]));
|
let key_id = format!("GK{}", hex::encode(&rand::random::<[u8; 12]>()[..]));
|
||||||
let secret_key = hex::encode(&rand::random::<[u8; 32]>()[..]);
|
let secret_key = hex::encode(&rand::random::<[u8; 32]>()[..]);
|
||||||
let ret = Self {
|
Self {
|
||||||
key_id,
|
key_id,
|
||||||
secret_key,
|
secret_key,
|
||||||
name: crdt::LWW::new(name),
|
name: crdt::LWW::new(name),
|
||||||
deleted: crdt::Bool::new(false),
|
deleted: crdt::Bool::new(false),
|
||||||
authorized_buckets: crdt::LWWMap::new(),
|
authorized_buckets: crdt::LWWMap::new(),
|
||||||
};
|
}
|
||||||
ret
|
|
||||||
}
|
}
|
||||||
pub fn delete(key_id: String) -> Self {
|
pub fn delete(key_id: String) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
Loading…
Reference in a new issue