Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
radicle: introduce specialised Stream types
Fintan Halpenny committed 8 months ago
commit 044ff8adde36b0f58a15ee448895e1374d2f7e0c
parent c0ac228c37cc70c4f5a662954659d6043b3ca1db
3 files changed +29 -0
modified crates/radicle/src/cob/identity.rs
@@ -12,6 +12,7 @@ use thiserror::Error;
use crate::identity::doc::Doc;
use crate::node::device::Device;
use crate::node::NodeId;
+
use crate::storage;
use crate::{
    cob,
    cob::{
@@ -38,6 +39,15 @@ pub type Op = cob::Op<Action>;
/// Identifier for an identity revision.
pub type RevisionId = EntryId;

+
pub type IdentityStream<'a> = cob::stream::Stream<'a, Action>;
+

+
impl<'a> IdentityStream<'a> {
+
    pub fn init(identity: ObjectId, store: &'a storage::git::Repository) -> Self {
+
        let history = cob::stream::CobRange::new(&TYPENAME, &identity);
+
        Self::new(&store.backend, history, TYPENAME.clone())
+
    }
+
}
+

/// Proposal operation.
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
modified crates/radicle/src/cob/issue.rs
@@ -19,6 +19,7 @@ use crate::identity::doc::DocError;
use crate::node::device::Device;
use crate::node::NodeId;
use crate::prelude::{Did, Doc, ReadRepository, RepoId};
+
use crate::storage;
use crate::storage::{HasRepoId, RepositoryError, WriteRepository};

pub use cache::Cache;
@@ -33,6 +34,15 @@ pub static TYPENAME: LazyLock<TypeName> =
/// Identifier for an issue.
pub type IssueId = ObjectId;

+
pub type IssueStream<'a> = cob::stream::Stream<'a, Action>;
+

+
impl<'a> IssueStream<'a> {
+
    pub fn init(issue: IssueId, store: &'a storage::git::Repository) -> Self {
+
        let history = cob::stream::CobRange::new(&TYPENAME, &issue);
+
        Self::new(&store.backend, history, TYPENAME.clone())
+
    }
+
}
+

/// Error updating or creating issues.
#[derive(Error, Debug)]
pub enum Error {
modified crates/radicle/src/cob/patch.rs
@@ -46,6 +46,15 @@ pub type Op = cob::Op<Action>;
/// Identifier for a patch.
pub type PatchId = ObjectId;

+
pub type PatchStream<'a> = cob::stream::Stream<'a, Action>;
+

+
impl<'a> PatchStream<'a> {
+
    pub fn init(patch: PatchId, store: &'a storage::git::Repository) -> Self {
+
        let history = cob::stream::CobRange::new(&TYPENAME, &patch);
+
        Self::new(&store.backend, history, TYPENAME.clone())
+
    }
+
}
+

/// Unique identifier for a patch revision.
#[derive(
    Wrapper,