pub trait DataTypeTrait<UserState>: PartialEq + Eq {
// Required methods
fn data_type_color(&self, user_state: &mut UserState) -> Color32;
fn name(&self) -> Cow<'_, str>;
}Expand description
This trait must be implemented by the DataType generic parameter of the
Graph. This trait tells the library how to visually expose data types
to the user.
Required Methods§
Sourcefn data_type_color(&self, user_state: &mut UserState) -> Color32
fn data_type_color(&self, user_state: &mut UserState) -> Color32
The associated port color of this datatype
Sourcefn name(&self) -> Cow<'_, str>
fn name(&self) -> Cow<'_, str>
The name of this datatype. Return type is specified as Cow
§Example (borrowed value)
Use this when you can get the name of the datatype from its fields or as a &’static str. Prefer this method when possible.
ⓘ
pub struct DataType { name: String }
impl DataTypeTrait<()> for DataType {
fn name(&self) -> std::borrow::Cow<str> {
Cow::Borrowed(&self.name)
}
}§Example (owned value)
Use this when you can’t derive the name of the datatype from its fields.
ⓘ
pub struct DataType { some_tag: i32 }
impl DataTypeTrait<()> for DataType {
fn name(&self) -> std::borrow::Cow<str> {
Cow::Owned(format!("Super amazing type #{}", self.some_tag))
}
}Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".