Skip to content

Commit 17520aa

Browse files
authored
kdf: impl Display and core::error::Error for Error (#2189)
Minimum viable trait impls for an error type
1 parent bf55539 commit 17520aa

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

kdf/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#![forbid(unsafe_code)]
99
#![warn(missing_docs, unused_qualifications)]
1010

11+
use core::fmt;
12+
1113
/// Key Derivation Function.
1214
///
1315
/// These functions deterministically produce uniformly random outputs suitable as key material.
@@ -26,5 +28,13 @@ pub trait Pbkdf: Kdf {}
2628
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
2729
pub struct Error;
2830

31+
impl fmt::Display for Error {
32+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
33+
f.write_str("KDF error")
34+
}
35+
}
36+
37+
impl core::error::Error for Error {}
38+
2939
/// Result type with the `kdf` crate's [`Error`].
3040
pub type Result<T> = core::result::Result<T, Error>;

0 commit comments

Comments
 (0)