diff --git a/crates/radicle/src/cob/op.rs b/crates/radicle/src/cob/op.rs index db34e53b..80804f52 100644 --- a/crates/radicle/src/cob/op.rs +++ b/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, +} + /// Error loading an `Op` from storage. #[derive(Error, Debug)] pub enum LoadError { @@ -112,6 +120,20 @@ impl Op { } } + pub fn manifest_of(store: &S, id: &git::Oid) -> Result + 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(store: &S, id: git::Oid) -> Result where