fire_crypto/error/
mod.rs

1use std::error::Error;
2use std::fmt;
3
4/// Either the length or the format of a slice is incorrect
5#[derive(Debug, Copy, Clone)]
6pub struct TryFromError(());
7
8impl TryFromError {
9	pub(crate) fn from_any<T>(_: T) -> Self {
10		Self(())
11	}
12}
13
14impl fmt::Display for TryFromError {
15	fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
16		f.write_str(
17			"TryFrom<&[u8]> failed: \
18			either the length is incorrect or the format",
19		)
20	}
21}
22
23impl Error for TryFromError {}
24
25/// Either the length or the format of a slice is incorrect
26#[derive(Debug, Copy, Clone)]
27#[non_exhaustive]
28pub enum DecodeError {
29	InvalidLength,
30	InvalidBytes,
31}
32
33impl DecodeError {
34	#[cfg(feature = "b64")]
35	pub(crate) fn inv_bytes<T>(_: T) -> Self {
36		Self::InvalidBytes
37	}
38}
39
40impl fmt::Display for DecodeError {
41	fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
42		fmt::Debug::fmt(self, f)
43	}
44}
45
46impl Error for DecodeError {}