pub struct MaterialDatabase { /* private fields */ }Expand description
In-memory material property database with fuzzy search and interpolation.
Implementations§
Source§impl MaterialDatabase
impl MaterialDatabase
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a database pre-populated with common engineering materials.
Sourcepub fn insert(&mut self, record: MaterialRecord)
pub fn insert(&mut self, record: MaterialRecord)
Insert a material record.
Sourcepub fn lookup(&self, name: &str) -> Option<&MaterialRecord>
pub fn lookup(&self, name: &str) -> Option<&MaterialRecord>
Exact lookup by name.
Sourcepub fn fuzzy_search(&self, query: &str) -> Vec<&MaterialRecord>
pub fn fuzzy_search(&self, query: &str) -> Vec<&MaterialRecord>
Fuzzy search: return all records whose name or tags contain query
(case-insensitive substring match).
Sourcepub fn interpolate(
&self,
name_a: &str,
name_b: &str,
t: f64,
) -> Option<MaterialRecord>
pub fn interpolate( &self, name_a: &str, name_b: &str, t: f64, ) -> Option<MaterialRecord>
Interpolate material properties between two named materials.
Returns a new MaterialRecord with blended properties at weight t
(0 = pure first material, 1 = pure second material).
Returns None if either material is not found.
Trait Implementations§
Source§impl Debug for MaterialDatabase
impl Debug for MaterialDatabase
Source§impl Default for MaterialDatabase
impl Default for MaterialDatabase
Source§fn default() -> MaterialDatabase
fn default() -> MaterialDatabase
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MaterialDatabase
impl RefUnwindSafe for MaterialDatabase
impl Send for MaterialDatabase
impl Sync for MaterialDatabase
impl Unpin for MaterialDatabase
impl UnsafeUnpin for MaterialDatabase
impl UnwindSafe for MaterialDatabase
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<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.