Skip to main content

ironfix_fast/
error.rs

1/******************************************************************************
2   Author: Joaquín Béjar García
3   Email: jb@taunais.com
4   Date: 27/1/26
5******************************************************************************/
6
7//! FAST protocol error types.
8
9use thiserror::Error;
10
11/// Errors that can occur during FAST encoding/decoding.
12#[derive(Debug, Error, Clone, PartialEq, Eq)]
13pub enum FastError {
14    /// Unexpected end of input.
15    #[error("unexpected end of input")]
16    UnexpectedEof,
17
18    /// Unknown template ID.
19    #[error("unknown template id: {0}")]
20    UnknownTemplate(u32),
21
22    /// Invalid presence map.
23    #[error("invalid presence map")]
24    InvalidPresenceMap,
25
26    /// Integer overflow during decoding.
27    #[error("integer overflow")]
28    IntegerOverflow,
29
30    /// Invalid string encoding.
31    #[error("invalid string encoding")]
32    InvalidString,
33
34    /// Invalid decimal encoding.
35    #[error("invalid decimal: exponent={exponent}, mantissa={mantissa}")]
36    InvalidDecimal {
37        /// Decimal exponent.
38        exponent: i32,
39        /// Decimal mantissa.
40        mantissa: i64,
41    },
42
43    /// Missing mandatory field.
44    #[error("missing mandatory field: {name}")]
45    MissingMandatoryField {
46        /// Field name.
47        name: String,
48    },
49
50    /// Invalid operator application.
51    #[error("invalid operator: {0}")]
52    InvalidOperator(String),
53
54    /// Dictionary entry not found.
55    #[error("dictionary entry not found: {key}")]
56    DictionaryEntryNotFound {
57        /// Dictionary key.
58        key: String,
59    },
60
61    /// Sequence length mismatch.
62    #[error("sequence length mismatch: expected {expected}, got {actual}")]
63    SequenceLengthMismatch {
64        /// Expected length.
65        expected: u32,
66        /// Actual length.
67        actual: u32,
68    },
69}