Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
radicle: add Op::manifest_of
Fintan Halpenny committed 8 months ago
commit dbfcf424d6149677524a06330981aba80dd2eb24
parent bfe8c5234f79287d23ec1ace72d59dc1dcb54e35
1 file changed +23 -1
modified crates/radicle/src/cob/op.rs
@@ -3,10 +3,10 @@ use radicle_cob::Manifest;
use serde::Serialize;
use thiserror::Error;

-
use radicle_cob as cob;
use radicle_cob::history::{Entry, EntryId};
use radicle_crypto::PublicKey;

+
use crate::cob;
use crate::cob::Timestamp;
use crate::identity::DocAt;
use crate::storage::ReadRepository;
@@ -24,6 +24,14 @@ pub enum OpEncodingError {
    Git(#[from] git2::Error),
}

+
#[derive(Error, Debug)]
+
#[error("failed to load manifest of '{object}': {err}")]
+
pub struct ManifestError {
+
    object: git::Oid,
+
    #[source]
+
    err: Box<dyn std::error::Error + Send + Sync + 'static>,
+
}
+

/// Error loading an `Op` from storage.
#[derive(Error, Debug)]
pub enum LoadError {
@@ -112,6 +120,20 @@ impl<A> Op<A> {
        }
    }

+
    pub fn manifest_of<S>(store: &S, id: &git::Oid) -> Result<Manifest, ManifestError>
+
    where
+
        S: cob::change::Storage<
+
            ObjectId = git::Oid,
+
            Parent = git::Oid,
+
            Signatures = crypto::ssh::ExtendedSignature,
+
        >,
+
    {
+
        store.manifest_of(id).map_err(|err| ManifestError {
+
            object: *id,
+
            err: Box::new(err),
+
        })
+
    }
+

    /// Get the `Op` identified by the `id` in the provided `store`.
    pub fn load<S>(store: &S, id: git::Oid) -> Result<Self, LoadError>
    where