new BranchType

pull/19/head
Niko PLP 7 months ago
parent c078be8924
commit dee89ebe7a
  1. 8
      Cargo.lock
  2. 11
      ng-net/src/app_protocol.rs
  3. 22
      ng-repo/src/types.rs

8
Cargo.lock generated

@ -3257,7 +3257,7 @@ checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54"
[[package]] [[package]]
name = "nextgraph" name = "nextgraph"
version = "0.1.0-preview.5" version = "0.1.0-preview.6"
dependencies = [ dependencies = [
"async-once-cell", "async-once-cell",
"async-std", "async-std",
@ -3311,7 +3311,7 @@ dependencies = [
[[package]] [[package]]
name = "ng-broker" name = "ng-broker"
version = "0.1.0-preview.3" version = "0.1.0-preview.6"
dependencies = [ dependencies = [
"async-std", "async-std",
"async-trait", "async-trait",
@ -3515,7 +3515,7 @@ dependencies = [
[[package]] [[package]]
name = "ng-verifier" name = "ng-verifier"
version = "0.1.0-preview.5" version = "0.1.0-preview.6"
dependencies = [ dependencies = [
"async-std", "async-std",
"async-trait", "async-trait",
@ -3538,7 +3538,7 @@ dependencies = [
[[package]] [[package]]
name = "ng-wallet" name = "ng-wallet"
version = "0.1.0-preview.5" version = "0.1.0-preview.6"
dependencies = [ dependencies = [
"aes-gcm-siv", "aes-gcm-siv",
"argon2", "argon2",

@ -59,6 +59,8 @@ pub enum NgAccessV0 {
pub enum TargetBranchV0 { pub enum TargetBranchV0 {
Chat, Chat,
Stream, Stream,
Comments,
BackLinks,
Context, Context,
Ontology, Ontology,
BranchId(BranchId), BranchId(BranchId),
@ -79,14 +81,13 @@ pub enum NuriTargetV0 {
Group(String), // shortname of a Group Group(String), // shortname of a Group
Repo(RepoId), Repo(RepoId),
Identity(UserId),
} }
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
pub struct NuriV0 { pub struct NuriV0 {
pub identity: Option<UserId>, // None for personal identity
pub target: NuriTargetV0, pub target: NuriTargetV0,
pub entire_store: bool, // If it is a store, will (try to) include all the docs belonging to the store pub entire_store: bool, // If it is a store, will include all the docs belonging to the store
pub object: Option<ObjectId>, // used only for FileGet. // cannot be used for queries. only to download an object (file,commit..) pub object: Option<ObjectId>, // used only for FileGet. // cannot be used for queries. only to download an object (file,commit..)
pub branch: Option<TargetBranchV0>, // if None, the main branch is chosen pub branch: Option<TargetBranchV0>, // if None, the main branch is chosen
@ -101,6 +102,7 @@ impl NuriV0 {
pub fn new_repo_target_from_string(repo_id_string: String) -> Result<Self, NgError> { pub fn new_repo_target_from_string(repo_id_string: String) -> Result<Self, NgError> {
let repo_id: RepoId = repo_id_string.as_str().try_into()?; let repo_id: RepoId = repo_id_string.as_str().try_into()?;
Ok(Self { Ok(Self {
identity: None,
target: NuriTargetV0::Repo(repo_id), target: NuriTargetV0::Repo(repo_id),
entire_store: false, entire_store: false,
object: None, object: None,
@ -114,6 +116,7 @@ impl NuriV0 {
pub fn new_private_store_target() -> Self { pub fn new_private_store_target() -> Self {
Self { Self {
identity: None,
target: NuriTargetV0::PrivateStore, target: NuriTargetV0::PrivateStore,
entire_store: false, entire_store: false,
object: None, object: None,
@ -126,6 +129,7 @@ impl NuriV0 {
} }
pub fn new_entire_user_site() -> Self { pub fn new_entire_user_site() -> Self {
Self { Self {
identity: None,
target: NuriTargetV0::UserSite, target: NuriTargetV0::UserSite,
entire_store: false, entire_store: false,
object: None, object: None,
@ -149,6 +153,7 @@ impl NuriV0 {
let id = decode_id(j)?; let id = decode_id(j)?;
let key = decode_sym_key(k)?; let key = decode_sym_key(k)?;
Ok(Self { Ok(Self {
identity: None,
target: NuriTargetV0::PrivateStore, target: NuriTargetV0::PrivateStore,
entire_store: false, entire_store: false,
object: Some(id), object: Some(id),

@ -1344,10 +1344,17 @@ pub enum Branch {
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub enum BranchType { pub enum BranchType {
Main, // Main is also transactional Main, // Main is also transactional
Chat,
Store, Store,
Overlay, Overlay,
User, User,
// special transactional branches
Chat,
Stream,
Comments,
BackLinks,
Context,
Ontology,
Transactional, // this could have been called OtherTransactional, but for the sake of simplicity, we use Transactional for any branch that is not the Main one. Transactional, // this could have been called OtherTransactional, but for the sake of simplicity, we use Transactional for any branch that is not the Main one.
Root, // only used for BranchInfo Root, // only used for BranchInfo
//Unknown, // only used temporarily when loading a branch info from commits (Branch commit, then AddBranch commit) //Unknown, // only used temporarily when loading a branch info from commits (Branch commit, then AddBranch commit)
@ -1360,12 +1367,17 @@ impl fmt::Display for BranchType {
"{}", "{}",
match self { match self {
Self::Main => "Main", Self::Main => "Main",
Self::Chat => "Chat",
Self::Store => "Store", Self::Store => "Store",
Self::Overlay => "Overlay", Self::Overlay => "Overlay",
Self::User => "User", Self::User => "User",
Self::Transactional => "Transactional", Self::Transactional => "Transactional",
Self::Root => "Root", Self::Root => "Root",
Self::Chat => "Chat",
Self::Stream => "Stream",
Self::Comments => "Comments",
Self::BackLinks => "BackLinks",
Self::Context => "Context",
Self::Ontology => "Ontology",
//Self::Unknown => "==unknown==", //Self::Unknown => "==unknown==",
} }
) )
@ -1580,7 +1592,7 @@ impl RemovePermission {
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub enum RepoNamedItemV0 { pub enum RepoNamedItemV0 {
Branch(BranchId), Branch(BranchId),
Commit(ObjectId), Commit(ObjectRef),
} }
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
@ -1597,7 +1609,7 @@ pub struct AddNameV0 {
/// the name. in case of conflict, the smallest Id is taken. /// the name. in case of conflict, the smallest Id is taken.
pub name: String, pub name: String,
/// A branch, commit or file /// A branch or commit
pub item: RepoNamedItem, pub item: RepoNamedItem,
/// Metadata /// Metadata
@ -1634,7 +1646,7 @@ pub enum RemoveName {
/// Adds a repo into the store branch. /// Adds a repo into the store branch.
/// ///
/// The repo's `store` field should match the store /// The repo's `store` field should match the destination store
/// DEPS to the previous AddRepo commit(s) if it is an update. in this case, repo_id of the referenced rootbranch definition(s) should match /// DEPS to the previous AddRepo commit(s) if it is an update. in this case, repo_id of the referenced rootbranch definition(s) should match
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct AddRepoV0 { pub struct AddRepoV0 {

Loading…
Cancel
Save