Skip to content

Commit 0055b61

Browse files
committed
Add Hex error to Error
1 parent 5475921 commit 0055b61

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

negentropy/src/bytes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use alloc::string::String;
55
use alloc::vec::Vec;
66
use core::ops::Deref;
77

8-
use crate::hex;
8+
use crate::{hex, Error};
99

1010
/// Bytes
1111
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
@@ -33,7 +33,7 @@ impl Bytes {
3333
}
3434

3535
/// Construct from hex
36-
pub fn from_hex<T>(data: T) -> Result<Self, hex::Error>
36+
pub fn from_hex<T>(data: T) -> Result<Self, Error>
3737
where
3838
T: AsRef<[u8]>,
3939
{

negentropy/src/lib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use core::fmt;
2828
use std::collections::HashSet;
2929

3030
mod bytes;
31-
pub mod hex;
31+
mod hex;
3232
mod sha256;
3333

3434
pub use self::bytes::Bytes;
@@ -78,6 +78,8 @@ pub enum Error {
7878
/// Found output
7979
found: String,
8080
},
81+
/// Hex error
82+
Hex(hex::Error),
8183
}
8284

8385
#[cfg(feature = "std")]
@@ -108,10 +110,17 @@ impl fmt::Display for Error {
108110
"Unexpected output: expected={}, found={}",
109111
expected, found
110112
),
113+
Self::Hex(e) => write!(f, "Hex: {}", e),
111114
}
112115
}
113116
}
114117

118+
impl From<hex::Error> for Error {
119+
fn from(e: hex::Error) -> Self {
120+
Self::Hex(e)
121+
}
122+
}
123+
115124
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
116125
struct Item {
117126
timestamp: u64,

0 commit comments

Comments
 (0)