1use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, ProtocolError>;
7
8#[derive(Debug, Error, Clone)]
10pub struct ProtocolError(pub &'static str);
11
12impl ProtocolError {
13 pub fn coerce_static_from_str(error_str: &str) -> Self {
17 let coerce_static = Box::leak(error_str.to_string().into_boxed_str());
18 ProtocolError(coerce_static)
19 }
20}
21
22impl std::fmt::Display for ProtocolError {
23 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
24 write!(f, "{}", self.0)
25 }
26}
27
28use bigdecimal::ParseBigDecimalError;
29
30impl From<ParseBigDecimalError> for ProtocolError {
31 fn from(_err: ParseBigDecimalError) -> Self {
32 ProtocolError("Error converting to BigDecimal")
33 }
34}