pub struct MaterialFilter {
pub category_prefix: Option<String>,
pub min_values: HashMap<String, f64>,
pub max_values: HashMap<String, f64>,
}Expand description
Chainable filter for material databases.
Filters can be composed: call filter_category, filter_min, filter_max
in sequence and collect results with apply.
Fields§
§category_prefix: Option<String>Optional category prefix filter.
min_values: HashMap<String, f64>Per-property minimum value constraints.
max_values: HashMap<String, f64>Per-property maximum value constraints.
Implementations§
Source§impl MaterialFilter
impl MaterialFilter
Sourcepub fn filter_category(self, prefix: &str) -> Self
pub fn filter_category(self, prefix: &str) -> Self
Restrict to materials whose category starts with prefix.
Sourcepub fn filter_min(self, key: &str, min: f64) -> Self
pub fn filter_min(self, key: &str, min: f64) -> Self
Require property key >= min.
Sourcepub fn filter_max(self, key: &str, max: f64) -> Self
pub fn filter_max(self, key: &str, max: f64) -> Self
Require property key <= max.
Sourcepub fn apply<'a>(&self, db: &'a MaterialDatabase) -> Vec<&'a MaterialRecord>
pub fn apply<'a>(&self, db: &'a MaterialDatabase) -> Vec<&'a MaterialRecord>
Apply the filter to a database and return matching records.
Trait Implementations§
Source§impl Clone for MaterialFilter
impl Clone for MaterialFilter
Source§fn clone(&self) -> MaterialFilter
fn clone(&self) -> MaterialFilter
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MaterialFilter
impl Debug for MaterialFilter
Source§impl Default for MaterialFilter
impl Default for MaterialFilter
Source§fn default() -> MaterialFilter
fn default() -> MaterialFilter
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MaterialFilter
impl RefUnwindSafe for MaterialFilter
impl Send for MaterialFilter
impl Sync for MaterialFilter
impl Unpin for MaterialFilter
impl UnsafeUnpin for MaterialFilter
impl UnwindSafe for MaterialFilter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.