Skip to main content

MetadataFilter

Struct MetadataFilter 

Source
pub struct MetadataFilter { /* private fields */ }
Expand description

An expression, its matching policy, and its resource limits.

Boolean composition belongs to FilterExpression. This type only binds an already-built expression to the options and limits used to evaluate it.

§Examples

use qubit_metadata::FilterExpression;
use qubit_metadata::Metadata;
use qubit_metadata::MetadataFilter;

let metadata = Metadata::new().with("tenant", "acme");
let expression = FilterExpression::builder()
    .eq("tenant", "acme")
    .build()?;
let filter = MetadataFilter::builder().expression(expression).build()?;
assert!(filter.matches(&metadata));

Implementations§

Source§

impl MetadataFilter

Source

pub fn all() -> Self

Creates a filter that matches every metadata object.

§Returns

A constant-true filter using default match options and library hard limits.

Source

pub fn none() -> Self

Creates a filter that matches no metadata object.

§Returns

A constant-false filter using default match options and library hard limits.

Source

pub const fn builder() -> MetadataFilterBuilder

Creates a builder for a metadata filter.

Source

pub fn deserialize_with_filter_limits<'de, D>( deserializer: D, receiver_limits: FilterLimits, ) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserializes a filter and validates a receiver-controlled AST bound.

The receiver bound is charged while the AST is being decoded. Callers must separately bound raw input bytes and any deserializer-specific resources before accepting untrusted data.

§Parameters
  • deserializer - Source of the versioned filter representation.
  • receiver_limits - Local upper bounds applied to the decoded AST.
§Errors

Returns a deserialization error for malformed V1 data or an unsupported version. The underlying deserializer’s error type receives the structured filter-limit or policy failure through D::Error::custom; this generic API cannot return crate::MetadataWireDecodeError directly.

Source

pub fn decode_json_slice(input: &[u8]) -> Result<Self, MetadataWireDecodeError>

Decodes a strict metadata-filter JSON envelope using the default wire byte and receiver AST limits.

§Parameters
  • input - Complete untrusted JSON input.
§Returns

The decoded filter.

§Errors

Returns an input-size error before parsing, a nested-value limit error, UnsupportedVersion for a version mismatch, a structured filter-contract error, or InvalidJson for malformed strict filter input and receiver-limit failures found during incremental decoding.

Source

pub fn decode_json_slice_with_limits( input: &[u8], limits: MetadataLimits, receiver_filter_limits: FilterLimits, ) -> Result<Self, MetadataWireDecodeError>

Decodes a strict metadata-filter JSON envelope after validating both wire-byte and receiver-controlled AST limits.

§Parameters
  • input - Complete untrusted JSON input.
  • limits - Shared JSON limits for this decoding session.
  • receiver_filter_limits - Local AST limits validated after decoding.
§Returns

The decoded filter constrained by receiver-controlled limits.

§Errors

Returns an input-size error before parsing, UnsupportedVersion for a version mismatch, a structured filter-contract error in Filter, or InvalidJson for syntax, strict-envelope, nested value, and receiver-limit failures. Receiver AST limits are charged while the expression tree is read; generic JSON traversal is handled by the shared budget adapter. Individual JSON strings and embedded value payloads remain bounded by the outer input-byte limit.

Source

pub fn to_json_vec(&self) -> Result<Vec<u8>, MetadataWireEncodeError>

Encodes this filter with the default JSON budget profile.

Source

pub fn to_json_vec_with_limits( &self, limits: JsonEncodeLimits, ) -> Result<Vec<u8>, MetadataWireEncodeError>

Encodes this filter with caller-provided JSON budgets.

§Parameters
  • limits - Output and JSON-value budgets for this operation.
§Errors

Returns crate::MetadataWireEncodeError when encoding exceeds a budget or the filter cannot be represented by the V1 wire format.

Source

pub fn to_json_writer<W>( &self, writer: W, ) -> Result<(), MetadataWireEncodeError>
where W: Write,

Encodes this filter to a writer with the default JSON budget profile.

Source

pub fn to_json_writer_with_limits<W>( &self, writer: W, limits: JsonEncodeLimits, ) -> Result<(), MetadataWireEncodeError>
where W: Write,

Encodes this filter to a writer with caller-provided JSON budgets.

§Parameters
  • writer - Destination receiving the compact JSON document.
  • limits - Output and JSON-value budgets for this operation.
§Errors

Returns crate::MetadataWireEncodeError when encoding exceeds a budget, the filter cannot be represented by the V1 wire format, or the writer rejects the output.

Source

pub const fn expression(&self) -> &FilterExpression

Returns the root expression.

Source

pub const fn options(&self) -> FilterMatchOptions

Returns the evaluation options.

Source

pub const fn limits(&self) -> FilterLimits

Returns the resource limits.

Source

pub fn matches(&self, metadata: &Metadata) -> bool

Returns whether metadata satisfies this filter.

Trait Implementations§

Source§

impl Clone for MetadataFilter

Source§

fn clone(&self) -> MetadataFilter

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MetadataFilter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for MetadataFilter

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserializes a filter using library hard limits as receiver limits.

Source§

impl PartialEq for MetadataFilter

Source§

fn eq(&self, other: &MetadataFilter) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for MetadataFilter

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serializes this filter through its versioned wire representation.

Source§

impl StructuralPartialEq for MetadataFilter

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoValueDefault<T> for T

Source§

fn into_value_default(self) -> T

Converts this argument into the default value. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.