sensorlm-rs 0.1.0

SensorLM – wearable sensor foundation model in Rust (Burn + WGPU)
Documentation
//! Crate-wide error types.

use thiserror::Error;

/// All errors that can arise in `sensorlm-rs`.
#[derive(Debug, Error)]
pub enum SensorLMError {
    /// A tensor shape did not match expectations.
    #[error("Shape mismatch: expected {expected:?}, got {actual:?}")]
    ShapeMismatch {
        /// The shape that was required.
        expected: Vec<usize>,
        /// The shape that was actually observed.
        actual: Vec<usize>,
    },

    /// A captioning operation failed.
    #[error("Caption generation failed: {0}")]
    CaptionError(String),

    /// Dataset loading / parsing failed.
    #[error("Dataset error: {0}")]
    DatasetError(String),

    /// HTTP download failed.
    #[error("Download failed for '{url}': {source}")]
    DownloadError {
        /// The URL that was being fetched.
        url: String,
        /// The underlying reqwest error.
        #[source]
        source: reqwest::Error,
    },

    /// File I/O error.
    #[error("I/O error: {0}")]
    Io(#[from] std::io::Error),

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

    /// Tokeniser error (opaque string from the `tokenizers` crate).
    #[error("Tokeniser error: {0}")]
    TokenizerError(String),

    /// Quantisation calibration error.
    #[error("Quantisation error: {0}")]
    QuantisationError(String),

    /// Generic catch-all from `anyhow`.
    #[error(transparent)]
    Other(#[from] anyhow::Error),
}

/// Shorthand result type used throughout the crate.
pub type Result<T> = std::result::Result<T, SensorLMError>;