pub trait Attribwhere
Self: Sized,{
Show 30 methods
// Required methods
fn attrib_size<I: AttribIndex<Self>>(&self) -> usize;
fn attrib_dict<I: AttribIndex<Self>>(&self) -> &AttribDict<I>;
fn attrib_dict_mut<I: AttribIndex<Self>>(&mut self) -> &mut AttribDict<I>;
fn attrib_dict_and_cache_mut<I: AttribIndex<Self>>(
&mut self
) -> (&mut AttribDict<I>, Option<&mut AttribValueCache>);
// Provided methods
fn insert_attrib_with_default<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
def: T
) -> Result<&mut Attribute<I>, Error>
where T: AttributeValue { ... }
fn insert_attrib_data<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
data: Vec<T>
) -> Result<&mut Attribute<I>, Error>
where T: AttributeValue + Default { ... }
fn reset_attrib_to_default<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
def: T
) -> Result<&mut Attribute<I>, Error>
where T: AttributeValue { ... }
fn set_attrib_data<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
data: Vec<T>
) -> Result<&mut Attribute<I>, Error>
where T: AttributeValue + Default { ... }
fn insert_indirect_attrib<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
def: T
) -> Result<(&mut Attribute<I>, &mut AttribValueCache), Error>
where T: AttributeValueHash { ... }
fn set_indirect_attrib<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
def: T
) -> Result<(&mut Attribute<I>, &mut AttribValueCache), Error>
where T: AttributeValueHash { ... }
fn insert_indirect_attrib_data<'a, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
data: IndirectData
) -> Result<(&mut Attribute<I>, &mut AttribValueCache), Error> { ... }
fn set_indirect_attrib_data<'a, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
data: IndirectData
) -> Result<(&mut Attribute<I>, &mut AttribValueCache), Error> { ... }
fn duplicate_attrib<'a, 'b, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
new_name: &'b str
) -> Result<&mut Attribute<I>, Error>
where T: Any + Clone { ... }
fn remove_attrib<I: AttribIndex<Self>>(
&mut self,
name: &str
) -> Result<Attribute<I>, Error> { ... }
fn insert_attrib<I: AttribIndex<Self>>(
&mut self,
name: &str,
attrib: Attribute<I>
) -> Result<Option<Attribute<I>>, Error> { ... }
fn attrib_or_insert_with_default<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
def: T
) -> Result<&mut Attribute<I>, Error>
where T: AttributeValue { ... }
fn attrib_or_insert_data<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
data: &[T]
) -> Result<&mut Attribute<I>, Error>
where T: AttributeValue + Default { ... }
fn attrib_or_insert_indirect<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
def: T
) -> Result<(&mut Attribute<I>, &mut AttribValueCache), Error>
where T: AttributeValueHash { ... }
fn direct_attrib_iter<'a, 'b, T, I: 'b + AttribIndex<Self>>(
&'b self,
name: &'a str
) -> Result<Iter<'_, T>, Error>
where T: Any + Clone { ... }
fn attrib_iter_mut<'a, 'b, T, I: 'b + AttribIndex<Self>>(
&'b mut self,
name: &'a str
) -> Result<IterMut<'_, T>, Error>
where T: Any + Clone { ... }
fn attrib_iter<'b, T, I: 'b + AttribIndex<Self>>(
&'b self,
name: &str
) -> Result<Box<dyn Iterator<Item = &'b T> + 'b>, Error>
where T: Any + Clone { ... }
fn indirect_attrib_update_with<'a, 'b, T, I, F>(
&'b mut self,
name: &'a str,
f: F
) -> Result<(&'b mut Attribute<I>, &'b mut AttribValueCache), Error>
where T: AttributeValueHash,
I: 'b + AttribIndex<Self>,
F: FnMut(usize, &Irc<T>) -> Option<Irc<T>> { ... }
fn attrib_exists<I: AttribIndex<Self>>(&self, name: &str) -> bool { ... }
fn attrib_check<'a, T: Any, I: AttribIndex<Self>>(
&self,
name: &'a str
) -> Result<&Attribute<I>, Error> { ... }
fn attrib_as_slice<'a, 'b, T: 'static, I: 'b + AttribIndex<Self>>(
&'b self,
name: &'a str
) -> Result<&'b [T], Error> { ... }
fn attrib_as_mut_slice<'a, 'b, T: 'static, I: 'b + AttribIndex<Self>>(
&'b mut self,
name: &'a str
) -> Result<&'b mut [T], Error> { ... }
fn attrib_clone_into_vec<'a, 'b, T, I: 'b + AttribIndex<Self>>(
&'b self,
name: &'a str
) -> Result<Vec<T>, Error>
where T: AttributeValueHash { ... }
fn direct_attrib_clone_into_vec<'a, 'b, T, I: 'b + AttribIndex<Self>>(
&'b self,
name: &'a str
) -> Result<Vec<T>, Error>
where T: AttributeValue { ... }
fn attrib<'a, I: AttribIndex<Self>>(
&self,
name: &'a str
) -> Result<&Attribute<I>, Error> { ... }
fn attrib_mut<'a, I: AttribIndex<Self>>(
&mut self,
name: &'a str
) -> Result<&mut Attribute<I>, Error> { ... }
}
Expand description
Attribute interfaces for meshes. In order to derive this trait the mesh must have a field
called attributes
with type AttribDict
.
Required Methods§
sourcefn attrib_size<I: AttribIndex<Self>>(&self) -> usize
fn attrib_size<I: AttribIndex<Self>>(&self) -> usize
Get the size of the attribute at the appropriate mesh location determined by I
.
sourcefn attrib_dict<I: AttribIndex<Self>>(&self) -> &AttribDict<I>
fn attrib_dict<I: AttribIndex<Self>>(&self) -> &AttribDict<I>
Read only access to the attribute dictionary.
sourcefn attrib_dict_mut<I: AttribIndex<Self>>(&mut self) -> &mut AttribDict<I>
fn attrib_dict_mut<I: AttribIndex<Self>>(&mut self) -> &mut AttribDict<I>
Read and write access to the attribute dictionary.
sourcefn attrib_dict_and_cache_mut<I: AttribIndex<Self>>(
&mut self
) -> (&mut AttribDict<I>, Option<&mut AttribValueCache>)
fn attrib_dict_and_cache_mut<I: AttribIndex<Self>>( &mut self ) -> (&mut AttribDict<I>, Option<&mut AttribValueCache>)
Read and write access to the attribute dictionary along with a cache for indirect attribute values.
Provided Methods§
sourcefn insert_attrib_with_default<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
def: T
) -> Result<&mut Attribute<I>, Error>where
T: AttributeValue,
fn insert_attrib_with_default<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
def: T
) -> Result<&mut Attribute<I>, Error>where
T: AttributeValue,
Insert an attribute at the appropriate location with a given default.
In an attribute with the same name already exists, an error is returned.
If an existing attribute should be overwritten, use
Attrib::reset_attrib_to_default
instead.
sourcefn insert_attrib_data<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
data: Vec<T>
) -> Result<&mut Attribute<I>, Error>where
T: AttributeValue + Default,
fn insert_attrib_data<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
data: Vec<T>
) -> Result<&mut Attribute<I>, Error>where
T: AttributeValue + Default,
Construct an attribute from a given data Vec<T>
. data
must have
exactly the right size for the attribute to be inserted successfully.
If an attribute with the same name already exists, an error is returned.
Use Attrib::set_attrib_data
to overwrite the attribute in such a
case.
sourcefn reset_attrib_to_default<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
def: T
) -> Result<&mut Attribute<I>, Error>where
T: AttributeValue,
fn reset_attrib_to_default<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
def: T
) -> Result<&mut Attribute<I>, Error>where
T: AttributeValue,
Resets the attribute to the specified default value whether or not it already exists.
sourcefn set_attrib_data<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
data: Vec<T>
) -> Result<&mut Attribute<I>, Error>where
T: AttributeValue + Default,
fn set_attrib_data<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
data: Vec<T>
) -> Result<&mut Attribute<I>, Error>where
T: AttributeValue + Default,
Set an attribute to the given data vector. data
must have exactly the
right size for the attribute to be set successfully.
If an attribute with the same name already exists, it is overwritten. To
avoid overwriting existing attributes use Attrib::insert_attrib_data
.
sourcefn insert_indirect_attrib<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
def: T
) -> Result<(&mut Attribute<I>, &mut AttribValueCache), Error>where
T: AttributeValueHash,
fn insert_indirect_attrib<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
def: T
) -> Result<(&mut Attribute<I>, &mut AttribValueCache), Error>where
T: AttributeValueHash,
Insert an indirect attribute at the appropriate location with a given default.
sourcefn set_indirect_attrib<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
def: T
) -> Result<(&mut Attribute<I>, &mut AttribValueCache), Error>where
T: AttributeValueHash,
fn set_indirect_attrib<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
def: T
) -> Result<(&mut Attribute<I>, &mut AttribValueCache), Error>where
T: AttributeValueHash,
Sets the indirect attribute to the specified default value whether or not it already exists.
sourcefn insert_indirect_attrib_data<'a, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
data: IndirectData
) -> Result<(&mut Attribute<I>, &mut AttribValueCache), Error>
fn insert_indirect_attrib_data<'a, I: AttribIndex<Self>>( &mut self, name: &'a str, data: IndirectData ) -> Result<(&mut Attribute<I>, &mut AttribValueCache), Error>
Construct an indirect attribute from a given IndirectData
. data
must have
exactly the right size for the attribute to be inserted successfully.
sourcefn set_indirect_attrib_data<'a, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
data: IndirectData
) -> Result<(&mut Attribute<I>, &mut AttribValueCache), Error>
fn set_indirect_attrib_data<'a, I: AttribIndex<Self>>( &mut self, name: &'a str, data: IndirectData ) -> Result<(&mut Attribute<I>, &mut AttribValueCache), Error>
Set an indirect attribute to the given IndirectData
instance. data
must have
exactly the right size for the attribute to be set successfully.
sourcefn duplicate_attrib<'a, 'b, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
new_name: &'b str
) -> Result<&mut Attribute<I>, Error>
fn duplicate_attrib<'a, 'b, T, I: AttribIndex<Self>>( &mut self, name: &'a str, new_name: &'b str ) -> Result<&mut Attribute<I>, Error>
Makes a copy of an existing attribute.
Return a mutable reference to the new attribute if successful.
sourcefn remove_attrib<I: AttribIndex<Self>>(
&mut self,
name: &str
) -> Result<Attribute<I>, Error>
fn remove_attrib<I: AttribIndex<Self>>( &mut self, name: &str ) -> Result<Attribute<I>, Error>
Remove an attribute from the attribute dictionary.
From there you can use methods defined on the returned attribute, and if desired return
it back to the dictionary with insert_attrib
.
sourcefn insert_attrib<I: AttribIndex<Self>>(
&mut self,
name: &str,
attrib: Attribute<I>
) -> Result<Option<Attribute<I>>, Error>
fn insert_attrib<I: AttribIndex<Self>>( &mut self, name: &str, attrib: Attribute<I> ) -> Result<Option<Attribute<I>>, Error>
Inserts an attribute into the dictionary with the usual HashMap
semantics.
This means that if an attribute with the same name exists, it will be returned and the
current table entry is updated with the new value. If it doesn’t already exist, None
is
returned.
sourcefn attrib_or_insert_with_default<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
def: T
) -> Result<&mut Attribute<I>, Error>where
T: AttributeValue,
fn attrib_or_insert_with_default<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
def: T
) -> Result<&mut Attribute<I>, Error>where
T: AttributeValue,
Retrieve the attribute with the given name and if it doesn’t exist, insert a new one and set it to a given default value. In either case the mutable reference to the attribute is returned.
sourcefn attrib_or_insert_data<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
data: &[T]
) -> Result<&mut Attribute<I>, Error>where
T: AttributeValue + Default,
fn attrib_or_insert_data<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
data: &[T]
) -> Result<&mut Attribute<I>, Error>where
T: AttributeValue + Default,
Retrieve the attribute with the given name and if it doesn’t exist, set its data to what’s in the given slice. In either case the mutable reference to the attribute is returned.
sourcefn attrib_or_insert_indirect<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
def: T
) -> Result<(&mut Attribute<I>, &mut AttribValueCache), Error>where
T: AttributeValueHash,
fn attrib_or_insert_indirect<'a, T, I: AttribIndex<Self>>(
&mut self,
name: &'a str,
def: T
) -> Result<(&mut Attribute<I>, &mut AttribValueCache), Error>where
T: AttributeValueHash,
Retrieve the indirect attribute with the given name and if it doesn’t exist, insert a new one and set it to a given default value. In either case the mutable reference to the attribute is returned.
sourcefn direct_attrib_iter<'a, 'b, T, I: 'b + AttribIndex<Self>>(
&'b self,
name: &'a str
) -> Result<Iter<'_, T>, Error>
fn direct_attrib_iter<'a, 'b, T, I: 'b + AttribIndex<Self>>( &'b self, name: &'a str ) -> Result<Iter<'_, T>, Error>
Get the attribute iterator for a direct attribute.
sourcefn attrib_iter_mut<'a, 'b, T, I: 'b + AttribIndex<Self>>(
&'b mut self,
name: &'a str
) -> Result<IterMut<'_, T>, Error>
fn attrib_iter_mut<'a, 'b, T, I: 'b + AttribIndex<Self>>( &'b mut self, name: &'a str ) -> Result<IterMut<'_, T>, Error>
Get the attribute mutable iterator for a direct attribute.
This is an alias for attrib_mut::<I>(name)?.direct_iter_mut::<T>()
.
sourcefn attrib_iter<'b, T, I: 'b + AttribIndex<Self>>(
&'b self,
name: &str
) -> Result<Box<dyn Iterator<Item = &'b T> + 'b>, Error>
fn attrib_iter<'b, T, I: 'b + AttribIndex<Self>>( &'b self, name: &str ) -> Result<Box<dyn Iterator<Item = &'b T> + 'b>, Error>
Get the iterator for an attribute no matter what kind.
This is an alias for attrib::<I>(name)?.iter::<T>()
.
sourcefn indirect_attrib_update_with<'a, 'b, T, I, F>(
&'b mut self,
name: &'a str,
f: F
) -> Result<(&'b mut Attribute<I>, &'b mut AttribValueCache), Error>
fn indirect_attrib_update_with<'a, 'b, T, I, F>( &'b mut self, name: &'a str, f: F ) -> Result<(&'b mut Attribute<I>, &'b mut AttribValueCache), Error>
Update indirect attribute entries with the given closure.
Return a mutable reference to Self
on success.
sourcefn attrib_exists<I: AttribIndex<Self>>(&self, name: &str) -> bool
fn attrib_exists<I: AttribIndex<Self>>(&self, name: &str) -> bool
Return true
if the given attribute exists at the given location, and
false
otherwise, even if the specified attribute location is invalid
for the mesh.
sourcefn attrib_check<'a, T: Any, I: AttribIndex<Self>>(
&self,
name: &'a str
) -> Result<&Attribute<I>, Error>
fn attrib_check<'a, T: Any, I: AttribIndex<Self>>( &self, name: &'a str ) -> Result<&Attribute<I>, Error>
Determine if the given attribute is valid and exists at the given location.
This is an alias for attrib::<I>(name)?.iter::<T>()
.
sourcefn attrib_as_slice<'a, 'b, T: 'static, I: 'b + AttribIndex<Self>>(
&'b self,
name: &'a str
) -> Result<&'b [T], Error>
fn attrib_as_slice<'a, 'b, T: 'static, I: 'b + AttribIndex<Self>>( &'b self, name: &'a str ) -> Result<&'b [T], Error>
Expose the underlying direct attribute as a slice.
This is an alias for attrib::<I>(name)?.as_slice::<T>()
.
sourcefn attrib_as_mut_slice<'a, 'b, T: 'static, I: 'b + AttribIndex<Self>>(
&'b mut self,
name: &'a str
) -> Result<&'b mut [T], Error>
fn attrib_as_mut_slice<'a, 'b, T: 'static, I: 'b + AttribIndex<Self>>( &'b mut self, name: &'a str ) -> Result<&'b mut [T], Error>
Expose the underlying direct attribute as a mutable slice.
This is an alias for attrib_mut::<I>(name)?.as_mut_slice::<T>()
.
sourcefn attrib_clone_into_vec<'a, 'b, T, I: 'b + AttribIndex<Self>>(
&'b self,
name: &'a str
) -> Result<Vec<T>, Error>where
T: AttributeValueHash,
fn attrib_clone_into_vec<'a, 'b, T, I: 'b + AttribIndex<Self>>(
&'b self,
name: &'a str
) -> Result<Vec<T>, Error>where
T: AttributeValueHash,
Clone attribute data into a Vec<T>
.
This works for direct and indirect attributes. Note that indirect attributes can be expensive to clone.
sourcefn direct_attrib_clone_into_vec<'a, 'b, T, I: 'b + AttribIndex<Self>>(
&'b self,
name: &'a str
) -> Result<Vec<T>, Error>where
T: AttributeValue,
fn direct_attrib_clone_into_vec<'a, 'b, T, I: 'b + AttribIndex<Self>>(
&'b self,
name: &'a str
) -> Result<Vec<T>, Error>where
T: AttributeValue,
Clone direct attribute data into a Vec<T>
.
This is an alias for attrib_mut::<I>(name)?.as_mut_slice::<T>()
.
sourcefn attrib<'a, I: AttribIndex<Self>>(
&self,
name: &'a str
) -> Result<&Attribute<I>, Error>
fn attrib<'a, I: AttribIndex<Self>>( &self, name: &'a str ) -> Result<&Attribute<I>, Error>
Borrow the raw attribute from the attribute dictionary.
From there you can use methods defined on the attribute itself.
sourcefn attrib_mut<'a, I: AttribIndex<Self>>(
&mut self,
name: &'a str
) -> Result<&mut Attribute<I>, Error>
fn attrib_mut<'a, I: AttribIndex<Self>>( &mut self, name: &'a str ) -> Result<&mut Attribute<I>, Error>
Get the raw mutable attribute from the attribute dictionary.
From there you can use methods defined on the attribute itself.