r2fas 0.2.1

radare2 core plugin that loads FASM -s symbolic dumps for named labels, source lines, and comments
//! Error types returned while parsing a FASM symbolic dump.

use thiserror::Error;

/// Failures that can occur while reading or interpreting a `.fas` file.
#[derive(Debug, Error)]
pub enum FasError {
    /// The buffer is shorter than the header, or a table offset/length is out of range.
    #[error("truncated or out-of-range FAS data: {0}")]
    Truncated(&'static str),

    /// Byte 0..4 is not the little-endian signature `1A736166h` (`"fas\\x1a"`).
    #[error("not a FASM symbolic dump (bad signature)")]
    BadSignature,

    /// A required table claimed a length that is not a multiple of its record size.
    #[error("invalid table geometry: {0}")]
    Geometry(&'static str),

    /// A string or Pascal name pointed past the owning table.
    #[error("invalid string reference: {0}")]
    BadString(&'static str),

    /// The filesystem could not supply the dump.
    #[error("I/O error: {0}")]
    Io(#[from] std::io::Error),
}

/// Convenient result alias for FAS parsing.
pub type Result<T> = std::result::Result<T, FasError>;