jacquardSnapshot

← snapshot

1372 bytes
//! Errors for the neutral-plane primitives.

use thiserror::Error;

/// Failures constructing or parsing core values.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Error)]
#[non_exhaustive]
pub enum CoreError {
    /// An identifier value of zero was supplied.
    #[error("identifier value must be non-zero")]
    ZeroIdentifier,

    /// An identifier string did not carry the expected prefix.
    #[error("identifier must start with `{expected}-`")]
    IdentifierPrefix {
        /// The prefix the identifier type renders with.
        expected: &'static str,
    },

    /// An identifier body was not 16 hex digits.
    #[error("identifier body must be 16 lowercase hex digits")]
    IdentifierBody,

    /// A digest string was not the expected length.
    #[error("digest must be 64 hex characters, got {len}")]
    MalformedDigest {
        /// Length of the rejected input.
        len: usize,
    },

    /// A digest string contained a non-hex character.
    #[error("digest contains a non-hex character")]
    MalformedDigestChar,

    /// Timestamp arithmetic overflowed.
    #[error("timestamp arithmetic out of range")]
    TimestampRange,

    /// A repository path was empty or contained an invalid segment.
    #[error("invalid repository path: {reason}")]
    InvalidPath {
        /// Why the path was rejected.
        reason: &'static str,
    },
}