datacard-rs 1.0.0

Generic binary card format library with checksums and pluggable format traits
Documentation
//! Error types for DataCard operations

use std::io;

/// Error types for DataCard operations
#[derive(Debug, thiserror::Error)]
pub enum CardError {
    #[error("IO error: {0}")]
    Io(#[from] io::Error),

    #[error("BytePunch error: {0}")]
    BytePunch(#[from] bytepunch_rs::BytePunchError),

    #[error("JSON error: {0}")]
    Json(#[from] serde_json::Error),

    #[error("Invalid magic bytes: got {0:?}")]
    InvalidMagic([u8; 4]),

    #[error("Unsupported version: {major}.{minor}")]
    UnsupportedVersion { major: u8, minor: u8 },

    #[error("Metadata too large: {0} bytes (max 65536)")]
    MetadataTooLarge(usize),

    #[error("Payload size mismatch: expected {expected}, got {actual}")]
    PayloadSizeMismatch { expected: u64, actual: usize },

    #[error("Checksum validation failed: expected {expected:08x}, got {actual:08x}")]
    ChecksumMismatch { expected: u32, actual: u32 },

    #[error("Invalid card format: {0}")]
    InvalidFormat(String),
}

pub type Result<T> = std::result::Result<T, CardError>;