diff --git a/crates/radicle/src/cob/identity.rs b/crates/radicle/src/cob/identity.rs index 814fe919..fad01e2e 100644 --- a/crates/radicle/src/cob/identity.rs +++ b/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; /// 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")] diff --git a/crates/radicle/src/cob/issue.rs b/crates/radicle/src/cob/issue.rs index 3ad1d82e..21a50f10 100644 --- a/crates/radicle/src/cob/issue.rs +++ b/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 = /// 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 { diff --git a/crates/radicle/src/cob/patch.rs b/crates/radicle/src/cob/patch.rs index 76c6f5e7..8c2daeca 100644 --- a/crates/radicle/src/cob/patch.rs +++ b/crates/radicle/src/cob/patch.rs @@ -46,6 +46,15 @@ pub type Op = cob::Op; /// 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,