Skip to content

Commit

Permalink
feat: Add helpers for MultihasherError (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
oblique authored Feb 9, 2024
1 parent 239705f commit f69ddd8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/multihasher.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::collections::VecDeque;
use std::fmt;
use std::fmt::{self, Display};

use async_trait::async_trait;
use libp2p_core::multihash::Multihash;
Expand Down Expand Up @@ -39,6 +39,16 @@ pub enum MultihasherError {
CustomFatal(String),
}

impl MultihasherError {
pub fn custom(e: impl Display) -> MultihasherError {
MultihasherError::Custom(e.to_string())
}

pub fn custom_fatal(e: impl Display) -> MultihasherError {
MultihasherError::CustomFatal(e.to_string())
}
}

/// Trait for producing a custom [`Multihash`].
#[async_trait]
pub trait Multihasher<const S: usize> {
Expand Down

0 comments on commit f69ddd8

Please sign in to comment.