vyre 0.4.0

GPU compute intermediate representation with a standard operation library
Documentation
//! Native scan match result.
//!
//! Scanning engines (DFA, Aho-Corasick, substring search) return `Match`
//! values to report where a pattern hit the input. This type is deliberately
//! minimal — just pattern ID and byte range — so that backends can return
//! matches with zero allocation overhead and consumers can interpret the
//! result without knowing the engine that produced it.

/// A byte-range match emitted by vyre scanning engines.
///
/// `Match` is the universal return type for every pattern-matching op in
/// vyre. It carries exactly the information a consumer needs to locate the
/// hit in the original input: the pattern that matched and the half-open
/// byte interval. The struct is `#[non_exhaustive]` so that future fields
/// (for example capture group indices) can be added without breaking the
/// frozen public API.
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Match {
    /// Stable pattern identifier that produced the match.
    pub pattern_id: u32,
    /// Inclusive byte start offset.
    pub start: u32,
    /// Exclusive byte end offset.
    pub end: u32,
}

impl Match {
    /// Construct a match from its pattern id and byte range.
    ///
    /// This constructor is a const fn so that engines can emit match
    /// literals at compile time. The byte range is half-open `[start, end)`
    /// to match Rust slicing conventions.
    ///
    /// # Examples
    ///
    /// ```
    /// use vyre::Match;
    ///
    /// let m = Match::new(1, 10, 20);
    /// assert_eq!(m.pattern_id, 1);
    /// assert_eq!(m.start, 10);
    /// assert_eq!(m.end, 20);
    /// ```
    #[must_use]
    pub const fn new(pattern_id: u32, start: u32, end: u32) -> Self {
        Self {
            pattern_id,
            start,
            end,
        }
    }
}