haz-query 0.1.0

Query evaluator over haz task DAGs.
Documentation
//! Atom-validation errors shared across the per-attribute
//! lifters in [`super`].

use haz_domain::name::NameError;
use haz_domain::path::PathPatternError;
use haz_query_lang::span::Span;
use snafu::Snafu;

/// Atom-validation failure produced while lifting a parsed atom
/// to its typed representation. Each variant captures the
/// offending byte span and the underlying validation error.
#[derive(Debug, Clone, PartialEq, Eq, Snafu)]
pub enum AtomError {
    /// Violates `QRY-003` for `--tags`: the atom text is not a
    /// valid `TagName` per `ID-001..ID-005`.
    #[snafu(display("invalid tag name at {span}: {source}"))]
    InvalidTagName {
        /// Span of the offending atom in the original input.
        span: Span,
        /// Underlying identifier-rule violation.
        source: NameError,
    },

    /// Violates `QRY-003` for `--projects`: the atom text is not
    /// a valid `ProjectName` per `ID-001..ID-005`.
    #[snafu(display("invalid project name at {span}: {source}"))]
    InvalidProjectName {
        /// Span of the offending atom in the original input.
        span: Span,
        /// Underlying identifier-rule violation.
        source: NameError,
    },

    /// Violates `QRY-003` for `--tasks`: the atom text is not a
    /// valid `TaskName` per `ID-001..ID-005`.
    #[snafu(display("invalid task name at {span}: {source}"))]
    InvalidTaskName {
        /// Span of the offending atom in the original input.
        span: Span,
        /// Underlying identifier-rule violation.
        source: NameError,
    },

    /// Violates `QRY-003` for `--inputs` / `--outputs`: the atom
    /// text is not a valid path pattern per
    /// `PATH-001..PATH-016`.
    #[snafu(display("invalid path pattern at {span}: {source}"))]
    InvalidPathPattern {
        /// Span of the offending atom in the original input.
        span: Span,
        /// Underlying path-pattern-rule violation.
        source: PathPatternError,
    },

    /// Violates `QRY-004`: the relational atom is missing the
    /// `:` separator between the kind keyword and the value.
    #[snafu(display("relational atom at {span} is missing the `:` separator"))]
    MissingRelationalColon {
        /// Span of the offending atom in the original input.
        span: Span,
    },

    /// Violates `QRY-004`: the kind keyword of the relational
    /// atom is not one of `name`, `project`, or `tag`
    /// (case-sensitive).
    #[snafu(display(
        "unknown relational kind '{kind}' at {span}; expected one of name, project, tag"
    ))]
    UnknownRelationalKind {
        /// Span of the offending atom in the original input.
        span: Span,
        /// The offending kind keyword as the user wrote it.
        kind: String,
    },
}