Added peer families to StateDB
. Relates to #5
This commit is contained in:
parent
4b00cef7e7
commit
a8a8d2968b
7 changed files with 193 additions and 8 deletions
20
ubisync-lib/src/types/family.rs
Normal file
20
ubisync-lib/src/types/family.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::{FamilyId, PeerId};
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
||||
pub struct Family {
|
||||
pub id: FamilyId,
|
||||
pub name: Option<String>,
|
||||
pub members: Vec<PeerId>,
|
||||
}
|
||||
|
||||
impl Family {
|
||||
pub fn new(id: FamilyId, name: Option<String>, members: Vec<PeerId>) -> Self {
|
||||
Family {
|
||||
id,
|
||||
name,
|
||||
members,
|
||||
}
|
||||
}
|
||||
}
|
11
ubisync-lib/src/types/family_id.rs
Normal file
11
ubisync-lib/src/types/family_id.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Default, Ord, PartialOrd, PartialEq, Eq, Hash)]
|
||||
pub struct FamilyId(Uuid);
|
||||
|
||||
impl FamilyId {
|
||||
pub fn new() -> Self {
|
||||
FamilyId { 0: Uuid::new_v4() }
|
||||
}
|
||||
}
|
|
@ -10,6 +10,12 @@ pub use element_id::ElementId;
|
|||
mod element;
|
||||
pub use element::Element;
|
||||
|
||||
mod family_id;
|
||||
pub use family_id::FamilyId;
|
||||
|
||||
mod family;
|
||||
pub use family::Family;
|
||||
|
||||
mod message_id;
|
||||
pub use message_id::MessageId;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ use anyhow::bail;
|
|||
use i2p::net::{I2pAddr, I2pSocketAddr, ToI2pSocketAddrs};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct PeerId {
|
||||
i2p_addr: I2pSocketAddr,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue