sheave_core/handlers/
inconsistent_sha.rs1use std::{
2 error::Error,
3 fmt::{
4 Display,
5 Formatter,
6 Result as FormatResult
7 },
8 io::{
9 Error as IOError,
10 ErrorKind
11 }
12};
13
14#[derive(Debug)]
16pub struct InconsistentSha(Vec<u8>);
17
18impl<'a> InconsistentSha {
19 pub fn new(sha: Vec<u8>) -> Self {
21 Self(sha)
22 }
23}
24
25impl Display for InconsistentSha {
26 fn fmt(&self, f: &mut Formatter<'_>) -> FormatResult {
27 writeln!(f, "Invalid SHA digest/signature: {:?}", self.0)
28 }
29}
30
31impl Error for InconsistentSha {}
32
33pub fn inconsistent_sha(sha: Vec<u8>) -> IOError {
35 IOError::new(
36 ErrorKind::InvalidData,
37 InconsistentSha(sha)
38 )
39}