Skip to main content

wafrift_encoding/
error.rs

1//! Error types for wafrift-encoding.
2
3/// Errors that can occur during encoding.
4#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
5pub enum EncodeError {
6    /// The input payload exceeds the maximum allowed size.
7    #[error("payload too large: {actual} bytes (max {max} bytes)")]
8    PayloadTooLarge { max: usize, actual: usize },
9    /// The accumulated layered output exceeds the maximum allowed size.
10    #[error("layered output too large: {actual} bytes (max {max} bytes)")]
11    LayeredOutputTooLarge { max: usize, actual: usize },
12    /// The payload contains invalid UTF-8 where valid UTF-8 is required.
13    #[error("payload contains invalid UTF-8")]
14    InvalidUtf8,
15    /// The requested strategy is not applicable in the given context.
16    #[error("strategy {strategy} is not valid in context {context}")]
17    InvalidContext {
18        strategy: &'static str,
19        context: String,
20    },
21    /// An internal configuration or I/O error occurred.
22    #[error("invalid config: {0}")]
23    InvalidConfig(String),
24}