pub struct FilterExpression { /* private fields */ }Expand description
An immutable Boolean expression in a crate::MetadataFilter.
Expressions are constructed by FilterExpressionBuilder and can be
inspected without allocation through FilterExpression::view. Their
private representation prevents callers from constructing structurally
invalid expression trees. The structure is Boolean, while evaluation uses
a private three-valued outcome so missing data stays unknown through NOT,
AND, and OR.
§Examples
use qubit_metadata::FilterExpression;
let expression = FilterExpression::builder()
.eq("tenant", "acme")
.build()?;
assert!(matches!(
expression.view(),
qubit_metadata::FilterExpressionView::Condition(_)
));Implementations§
Source§impl FilterExpression
impl FilterExpression
Sourcepub const fn builder() -> FilterExpressionBuilder
pub const fn builder() -> FilterExpressionBuilder
Creates a builder for a non-empty filter expression.
Sourcepub const fn match_none() -> Self
pub const fn match_none() -> Self
Creates an expression that matches no metadata object.
Sourcepub fn try_and(self, other: Self) -> MetadataResult<Self>
pub fn try_and(self, other: Self) -> MetadataResult<Self>
Combines this expression with other using logical AND.
§Parameters
other- Expression whose conditions must also match.
§Errors
Returns MetadataError::FilterLimitExceeded when the resulting
expression exceeds library hard limits.
Sourcepub fn try_or(self, other: Self) -> MetadataResult<Self>
pub fn try_or(self, other: Self) -> MetadataResult<Self>
Combines this expression with other using logical OR.
§Parameters
other- Expression whose conditions may also match.
§Errors
Returns MetadataError::FilterLimitExceeded when the resulting
expression exceeds library hard limits.
Sourcepub fn try_not(self) -> MetadataResult<Self>
pub fn try_not(self) -> MetadataResult<Self>
Negates this expression.
§Errors
Returns MetadataError::FilterLimitExceeded when the resulting
expression exceeds library hard limits.
Sourcepub fn view(&self) -> FilterExpressionView<'_>
pub fn view(&self) -> FilterExpressionView<'_>
Returns a borrowed view of this expression node.
§Returns
A zero-copy view preserving the node’s Boolean structure.
Trait Implementations§
Source§impl Clone for FilterExpression
impl Clone for FilterExpression
Source§impl Debug for FilterExpression
impl Debug for FilterExpression
Source§impl PartialEq for FilterExpression
impl PartialEq for FilterExpression
Source§impl Redact for FilterExpression
impl Redact for FilterExpression
Source§fn write_redacted(&self, writer: &mut RedactionWriter<'_>)
fn write_redacted(&self, writer: &mut RedactionWriter<'_>)
Writes the expression tree through the caller’s cumulative budget.
§Parameters
writer- Destination that receives the encoded or redacted output.