mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
chore(vault): implement std::errror::Error on CborConversionError
This commit is contained in:
parent
186e83bf9e
commit
371164b82f
1 changed files with 14 additions and 1 deletions
|
|
@ -1,3 +1,5 @@
|
|||
use std::fmt::Display;
|
||||
|
||||
use cbor::{self, cbor_array_vec, cbor_key_int, cbor_map, cbor_unsigned, destructure_cbor_map};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
|
@ -7,6 +9,17 @@ pub enum CborConversionError {
|
|||
UnknownAlgorithm(u64),
|
||||
}
|
||||
|
||||
impl Display for CborConversionError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
CborConversionError::BadCbor => write!(f, "bad cbor"),
|
||||
CborConversionError::UnknownAlgorithm(algo) => write!(f, "unknown algorithm {}", algo),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for CborConversionError {}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum HashAlgorithms {
|
||||
SHA1,
|
||||
|
|
@ -154,4 +167,4 @@ fn extract_string(cbor_value: cbor::Value) -> Result<String, CborConversionError
|
|||
cbor::Value::KeyValue(cbor::KeyType::TextString(string)) => Ok(string),
|
||||
_ => Err(CborConversionError::BadCbor),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue