torg_serde/
error.rs

1//! Error types for TØR-G serialization.
2
3use thiserror::Error;
4
5/// Errors that can occur during serialization/deserialization.
6#[derive(Error, Debug)]
7pub enum SerdeError {
8    /// Invalid magic bytes in binary format.
9    #[error("invalid magic bytes: expected 'TG', got {0:02X} {1:02X}")]
10    InvalidMagic(u8, u8),
11
12    /// Unsupported binary format version.
13    #[error("unsupported version: {0}")]
14    UnsupportedVersion(u8),
15
16    /// Invalid operation code in binary format.
17    #[error("invalid op code: {0}")]
18    InvalidOpCode(u8),
19
20    /// Invalid source tag in binary format.
21    #[error("invalid source tag: {0}")]
22    InvalidSourceTag(u8),
23
24    /// Unexpected end of input while reading binary format.
25    #[error("unexpected end of input at offset {0}")]
26    UnexpectedEof(usize),
27
28    /// JSON serialization/deserialization error.
29    #[error("JSON error: {0}")]
30    Json(#[from] serde_json::Error),
31
32    /// Graph validation error after deserialization.
33    #[error("invalid graph: {0}")]
34    InvalidGraph(String),
35}