radicle: introduce specialised Stream types
Add type aliases to specialise the `Stream` type for each of `Patch`, `Issue`, and `Identity`. An `init` constructor is also added for each to make it easier to construct each stream.
This commit is contained in:
parent
c0ac228c37
commit
044ff8adde
|
|
@ -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")]
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue