mirror of
https://github.com/zaphar/merkle-dag.git
synced 2025-07-22 02:29:49 -04:00
feat: store::Error implements std::error::Error
This commit is contained in:
parent
57953e1861
commit
f949ee7dac
21
src/store.rs
21
src/store.rs
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
//! The [Merkle Dag](crate::dag::Merkle) backing store trait.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::{collections::BTreeMap, error::Error, fmt};
|
||||
|
||||
use crate::{hash::HashWriter, node::Node};
|
||||
|
||||
@ -25,6 +25,25 @@ pub enum StoreError {
|
||||
NoSuchDependents,
|
||||
}
|
||||
|
||||
impl fmt::Display for StoreError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
StoreError::StoreFailure(msg) => write!(f, "{}", msg),
|
||||
StoreError::NoSuchDependents => write!(f, "No such Dependents"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for StoreError {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
None
|
||||
}
|
||||
|
||||
fn cause(&self) -> Option<&dyn Error> {
|
||||
self.source()
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(async_fn_in_trait)]
|
||||
/// Trait representing the backing storage interface for a [Merkle DAG](crate::dag::Merkle).
|
||||
pub trait AsyncStore<HW>
|
||||
|
Loading…
x
Reference in New Issue
Block a user