|
|
@ -19,6 +19,8 @@ use ng_repo::types::*; |
|
|
|
|
|
|
|
|
|
|
|
use serde_bare::to_vec; |
|
|
|
use serde_bare::to_vec; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use crate::server_broker::TopicInfo; |
|
|
|
|
|
|
|
|
|
|
|
pub struct Topic<'a> { |
|
|
|
pub struct Topic<'a> { |
|
|
|
key: Vec<u8>, |
|
|
|
key: Vec<u8>, |
|
|
|
repo: ExistentialValue<RepoHash>, |
|
|
|
repo: ExistentialValue<RepoHash>, |
|
|
@ -60,18 +62,23 @@ impl<'a> Topic<'a> { |
|
|
|
vec![&Self::USERS, &Self::HEADS], |
|
|
|
vec![&Self::USERS, &Self::HEADS], |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
pub fn load(&self) -> Result<(), StorageError> { |
|
|
|
pub fn load( |
|
|
|
let props = self.load_props()?; |
|
|
|
id: &TopicId, |
|
|
|
// let bs = BranchInfo {
|
|
|
|
overlay: &OverlayId, |
|
|
|
// id: id.clone(),
|
|
|
|
storage: &'a dyn KCVStorage, |
|
|
|
// branch_type: prop(Self::TYPE, &props)?,
|
|
|
|
) -> Result<TopicInfo, StorageError> { |
|
|
|
// read_cap: prop(Self::READ_CAP, &props)?,
|
|
|
|
let mut opening = Topic::new(id, overlay, storage); |
|
|
|
// topic: prop(Self::TOPIC, &props)?,
|
|
|
|
let props = opening.load_props()?; |
|
|
|
// topic_priv_key: prop(Self::PUBLISHER, &props).ok(),
|
|
|
|
let existential = col(&Self::REPO, &props)?; |
|
|
|
// current_heads: Self::get_all_heads(id, storage)?,
|
|
|
|
opening.repo.set(&existential, &opening)?; |
|
|
|
// };
|
|
|
|
let ti = TopicInfo { |
|
|
|
// Ok(bs)
|
|
|
|
repo: existential, |
|
|
|
Ok(()) |
|
|
|
publisher_advert: col(&Self::ADVERT, &props).ok(), |
|
|
|
|
|
|
|
root_commit: col(&Self::ROOT_COMMIT, &props).ok(), |
|
|
|
|
|
|
|
users: Self::USERS.get_all(&mut opening)?, |
|
|
|
|
|
|
|
current_heads: Self::HEADS.get_all(&mut opening)?, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
Ok(ti) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn new(id: &TopicId, overlay: &OverlayId, storage: &'a dyn KCVStorage) -> Self { |
|
|
|
pub fn new(id: &TopicId, overlay: &OverlayId, storage: &'a dyn KCVStorage) -> Self { |
|
|
|