oxgraph-postgres 0.3.2

Postgres-backed OxGraph engine: catalog, build, artifact I/O, query, sync.
Documentation
//! Search query types.

/// Search predicate over dense node ids (extension hydrates external columns).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SearchPredicate {
    /// Match a single dense node id.
    NodeId(u32),
    /// Match nodes whose id is within an inclusive range.
    NodeIdRange {
        /// Lower bound.
        start: u32,
        /// Upper bound.
        end: u32,
    },
}

impl SearchPredicate {
    /// Returns whether `node` satisfies this predicate.
    ///
    /// # Performance
    ///
    /// This method is `O(1)`.
    #[must_use]
    pub fn matches(self, node: u32) -> bool {
        match self {
            Self::NodeId(expected) => node == expected,
            Self::NodeIdRange { start, end } => (start..=end).contains(&node),
        }
    }
}