1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use std::fmt::{self, Display, Formatter};
#[derive(Debug)]
pub enum NoiseError {
TooShort,
DecryptionFailed,
}
impl From<()> for NoiseError {
fn from(_: ()) -> Self {
NoiseError::DecryptionFailed
}
}
impl Display for NoiseError {
fn fmt(&self, f: &mut Formatter) -> ::std::result::Result<(), fmt::Error> {
match *self {
NoiseError::TooShort => f.write_str("Message too short"),
NoiseError::DecryptionFailed => f.write_str("Decryption failed"),
}
}
}
impl ::std::error::Error for NoiseError {
fn description(&self) -> &str {
match *self {
NoiseError::TooShort => "Message too short",
NoiseError::DecryptionFailed => "Decryption failed",
}
}
}