Skip to main content

soe_protocol/
error.rs

1//! Error types for the SOE protocol crate.
2
3use std::result::Result as StdResult;
4
5/// A specialized [`Result`] type for SOE protocol operations.
6pub type Result<T> = StdResult<T, Error>;
7
8/// Errors that can occur while encoding, decoding or processing SOE protocol data.
9#[derive(Debug, thiserror::Error)]
10pub enum Error {
11    /// A buffer was too short to read or write the expected data.
12    #[error("buffer too short: needed {needed} bytes but only {available} available")]
13    BufferTooShort {
14        /// The number of bytes required.
15        needed: usize,
16        /// The number of bytes available.
17        available: usize,
18    },
19
20    /// A value did not fit within the expected bounds.
21    #[error("value out of range: {0}")]
22    OutOfRange(String),
23
24    /// A zlib (de)compression error occurred.
25    #[error("zlib error: {0}")]
26    Zlib(#[from] std::io::Error),
27}