pub struct Material {
pub name: String,
pub category: MaterialCategory,
pub description: Option<String>,
pub properties: HashMap<PropertyId, PropertyValue>,
}Expand description
A material definition with its properties.
Fields§
§name: StringUnique material name.
category: MaterialCategoryMaterial category.
description: Option<String>Optional description.
properties: HashMap<PropertyId, PropertyValue>Material properties.
Implementations§
Source§impl Material
impl Material
Sourcepub fn new(name: impl Into<String>, category: MaterialCategory) -> Self
pub fn new(name: impl Into<String>, category: MaterialCategory) -> Self
Create a new material.
Sourcepub fn with_property(self, id: PropertyId, value: f64) -> Self
pub fn with_property(self, id: PropertyId, value: f64) -> Self
Set a constant property.
Sourcepub fn with_temp_property(self, id: PropertyId, points: Vec<(f64, f64)>) -> Self
pub fn with_temp_property(self, id: PropertyId, points: Vec<(f64, f64)>) -> Self
Set a temperature-dependent property.
Sourcepub fn with_description(self, desc: impl Into<String>) -> Self
pub fn with_description(self, desc: impl Into<String>) -> Self
Set description.
Sourcepub fn get_property(&self, id: PropertyId, temperature_k: f64) -> Option<f64>
pub fn get_property(&self, id: PropertyId, temperature_k: f64) -> Option<f64>
Get a property value at a given temperature.
Sourcepub fn get_property_rt(&self, id: PropertyId) -> Option<f64>
pub fn get_property_rt(&self, id: PropertyId) -> Option<f64>
Get a property at room temperature (293.15 K / 20 C).
Sourcepub fn has_property(&self, id: PropertyId) -> bool
pub fn has_property(&self, id: PropertyId) -> bool
Check if this material has a given property.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Material
impl<'de> Deserialize<'de> for Material
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Material
impl RefUnwindSafe for Material
impl Send for Material
impl Sync for Material
impl Unpin for Material
impl UnsafeUnpin for Material
impl UnwindSafe for Material
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more