semantic-scene 0.1.1

Rust parser for semantic scene descriptors, currently focused on Habitat-Sim Matterport3D .house files.
Documentation
//! Error types returned by parsers and loaders.
use thiserror::Error;

/// Error returned while parsing one descriptor record.
#[derive(Debug, Error)]
pub enum ParseError {
    /// A required whitespace-delimited field was absent.
    #[error("missing field {field}")]
    MissingField {
        /// Zero-based field index in the record.
        field: usize,
    },
    /// A field existed but could not be parsed as the expected type.
    #[error("bad field {field}: {value}")]
    BadField {
        /// Zero-based field index in the record.
        field: usize,
        /// Original field text.
        value: String,
    },
    /// The record shape is not valid for its tag.
    #[error("bad line: {0}")]
    BadLine(String),
}

/// Error returned while loading and validating a semantic scene descriptor.
#[derive(Debug, Error)]
pub enum LoadError {
    /// The descriptor could not be read.
    #[error(transparent)]
    Io(#[from] std::io::Error),
    /// The file header is not supported by the selected loader.
    #[error("bad MP3D house header: {found}")]
    BadHeader {
        /// Header text found in the file.
        found: String,
    },
    /// A line failed to parse.
    #[error("parse error on line {line_number}: {source}; line: {line}")]
    ParseLine {
        /// One-based line number in the source file.
        line_number: usize,
        /// Original line text.
        line: String,
        /// Structured parse failure.
        source: ParseError,
    },
    /// A record referenced a parent record that does not exist.
    #[error("missing {kind} parent index {index} on line {line_number}")]
    MissingParent {
        /// One-based line number in the source file.
        line_number: usize,
        /// Parent kind, such as `level`, `region`, or `object`.
        kind: &'static str,
        /// Source-format parent index.
        index: i32,
    },
    /// An object referenced a category that does not exist.
    #[error("missing category index {index} on line {line_number}")]
    MissingCategory {
        /// One-based line number in the source file.
        line_number: usize,
        /// Source-format category index.
        index: i32,
    },
    /// Two segment records used the same semantic segment id.
    #[error("duplicate semantic segment id {segment_id} on line {line_number}")]
    DuplicateSegmentId {
        /// One-based line number in the source file.
        line_number: usize,
        /// Duplicate semantic mesh segment id.
        segment_id: i32,
    },
    /// The loader option is recognized but not implemented yet.
    #[error("unsupported option: {0}")]
    UnsupportedOption(&'static str),
}