wafrift_encoding/
error.rs1#[derive(Debug, Clone, PartialEq, Eq)]
5pub enum EncodeError {
6 PayloadTooLarge { max: usize, actual: usize },
8 LayeredOutputTooLarge { max: usize, actual: usize },
10 InvalidUtf8,
12 InvalidContext {
14 strategy: &'static str,
15 context: String,
16 },
17 InvalidConfig(String),
19}
20
21impl std::fmt::Display for EncodeError {
22 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23 match self {
24 Self::PayloadTooLarge { max, actual } => {
25 write!(f, "payload too large: {actual} bytes (max {max} bytes)")
26 }
27 Self::LayeredOutputTooLarge { max, actual } => {
28 write!(
29 f,
30 "layered output too large: {actual} bytes (max {max} bytes)"
31 )
32 }
33 Self::InvalidUtf8 => f.write_str("payload contains invalid UTF-8"),
34 Self::InvalidContext { strategy, context } => {
35 write!(f, "strategy {strategy} is not valid in context {context}")
36 }
37 Self::InvalidConfig(msg) => write!(f, "invalid config: {msg}"),
38 }
39 }
40}
41
42impl std::error::Error for EncodeError {}