crisol-core 1.2.0

Crisol core: an egui-free data model, themes, metrics, localization, commands, state, and storage.
Documentation
//! The core-wide error envelope for operations that cross module boundaries.
//!
//! ```
//! use crisol_core::error;
//! ```

/// A failure that does not belong to one specific subsystem.
///
/// Subsystems return their own error types (`DataError`, `StorageError`, `ThemeImportError`,
/// …); this envelope is for generic helpers and for callers that need one type.
#[derive(Clone, Debug, PartialEq, Eq, thiserror::Error)]
#[non_exhaustive]
/// # Example
///
/// ```
/// use crisol_core::error::CoreError;
/// ```
pub enum CoreError {
    /// An input value was rejected.
    #[error("{0}")]
    Invalid(&'static str),
    /// A versioned file is newer than the code understands.
    #[error("version {found} is newer than {latest}")]
    UnsupportedVersion {
        /// The version found in the file.
        found: u32,
        /// The newest version this build writes.
        latest: u32,
    },
    /// An I/O operation failed.
    #[error("{0}")]
    Io(String),
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn errors_are_send_sync_and_static() {
        fn assert_impl<T: Send + Sync + 'static>() {}
        assert_impl::<CoreError>();
        assert_eq!(
            CoreError::UnsupportedVersion { found: 2, latest: 1 }.to_string(),
            "version 2 is newer than 1"
        );
    }
}