numbat_codec/
codec_err.rs

1#[derive(Debug, PartialEq, Eq)]
2pub struct EncodeError(&'static [u8]);
3
4impl From<&'static [u8]> for EncodeError {
5	#[inline]
6	fn from(bytes: &'static [u8]) -> Self {
7		EncodeError(bytes)
8	}
9}
10
11impl EncodeError {
12	#[inline]
13	pub fn message_bytes(&self) -> &'static [u8] {
14		self.0
15	}
16
17	pub const UNSUPPORTED_OPERATION: EncodeError = EncodeError(b"unsupported operation");
18}
19
20#[derive(Debug, PartialEq, Eq)]
21pub struct DecodeError(&'static [u8]);
22
23impl From<&'static [u8]> for DecodeError {
24	#[inline]
25	fn from(bytes: &'static [u8]) -> Self {
26		DecodeError(bytes)
27	}
28}
29
30impl DecodeError {
31	#[inline]
32	pub fn message_bytes(&self) -> &'static [u8] {
33		self.0
34	}
35
36	pub const INPUT_TOO_SHORT: DecodeError = DecodeError(b"input too short");
37	pub const INPUT_TOO_LONG: DecodeError = DecodeError(b"input too long");
38	pub const INPUT_OUT_OF_RANGE: DecodeError = DecodeError(b"input out of range");
39	pub const INVALID_VALUE: DecodeError = DecodeError(b"invalid value");
40	pub const UNSUPPORTED_OPERATION: DecodeError = DecodeError(b"unsupported operation");
41	pub const ARRAY_DECODE_ERROR: DecodeError = DecodeError(b"array decode error");
42	pub const UTF8_DECODE_ERROR: DecodeError = DecodeError(b"utf-8 decode error");
43}