Skip to content

Commit f69ddd8

Browse files
authored
feat: Add helpers for MultihasherError (#25)
1 parent 239705f commit f69ddd8

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/multihasher.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::collections::VecDeque;
2-
use std::fmt;
2+
use std::fmt::{self, Display};
33

44
use async_trait::async_trait;
55
use libp2p_core::multihash::Multihash;
@@ -39,6 +39,16 @@ pub enum MultihasherError {
3939
CustomFatal(String),
4040
}
4141

42+
impl MultihasherError {
43+
pub fn custom(e: impl Display) -> MultihasherError {
44+
MultihasherError::Custom(e.to_string())
45+
}
46+
47+
pub fn custom_fatal(e: impl Display) -> MultihasherError {
48+
MultihasherError::CustomFatal(e.to_string())
49+
}
50+
}
51+
4252
/// Trait for producing a custom [`Multihash`].
4353
#[async_trait]
4454
pub trait Multihasher<const S: usize> {

0 commit comments

Comments
 (0)