bft_bench_core/
result.rs

1use std::{borrow::Cow, error::Error, fmt::Display};
2
3#[derive(Debug)]
4pub struct BftError {
5    message: Cow<'static, str>,
6}
7
8impl Error for BftError {}
9
10impl BftError {
11    pub fn fixed(message: &'static str) -> Self {
12        BftError {
13            message: Cow::Borrowed(message),
14        }
15    }
16
17    pub fn dynamic(message: String) -> Self {
18        BftError {
19            message: Cow::Owned(message),
20        }
21    }
22}
23
24impl Display for BftError {
25    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26        f.write_str(&self.message)
27    }
28}
29
30pub type Result<T> = core::result::Result<T, BftError>;