Trait meshx::attrib::Attrib

source ·
pub trait Attrib
where 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§

source

fn attrib_size<I: AttribIndex<Self>>(&self) -> usize

Get the size of the attribute at the appropriate mesh location determined by I.

source

fn attrib_dict<I: AttribIndex<Self>>(&self) -> &AttribDict<I>

Read only access to the attribute dictionary.

source

fn attrib_dict_mut<I: AttribIndex<Self>>(&mut self) -> &mut AttribDict<I>

Read and write access to the attribute dictionary.

source

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§

source

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.

source

fn insert_attrib_data<'a, T, I: AttribIndex<Self>>( &mut self, name: &'a str, data: Vec<T> ) -> Result<&mut Attribute<I>, Error>

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.

source

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.

source

fn set_attrib_data<'a, T, I: AttribIndex<Self>>( &mut self, name: &'a str, data: Vec<T> ) -> Result<&mut Attribute<I>, Error>

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.

source

fn insert_indirect_attrib<'a, T, I: AttribIndex<Self>>( &mut self, name: &'a str, def: T ) -> Result<(&mut Attribute<I>, &mut AttribValueCache), Error>

Insert an indirect attribute at the appropriate location with a given default.

source

fn set_indirect_attrib<'a, T, I: AttribIndex<Self>>( &mut self, name: &'a str, def: T ) -> Result<(&mut Attribute<I>, &mut AttribValueCache), Error>

Sets the indirect attribute to the specified default value whether or not it already exists.

source

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.

source

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.

source

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,

Makes a copy of an existing attribute.

Return a mutable reference to the new attribute if successful.

source

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.

source

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.

source

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.

source

fn attrib_or_insert_data<'a, T, I: AttribIndex<Self>>( &mut self, name: &'a str, data: &[T] ) -> Result<&mut Attribute<I>, Error>

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.

source

fn attrib_or_insert_indirect<'a, T, I: AttribIndex<Self>>( &mut self, name: &'a str, def: T ) -> Result<(&mut Attribute<I>, &mut AttribValueCache), Error>

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.

source

fn direct_attrib_iter<'a, 'b, T, I: 'b + AttribIndex<Self>>( &'b self, name: &'a str ) -> Result<Iter<'_, T>, Error>
where T: Any + Clone,

Get the attribute iterator for a direct attribute.

source

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,

Get the attribute mutable iterator for a direct attribute.

This is an alias for attrib_mut::<I>(name)?.direct_iter_mut::<T>().

source

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,

Get the iterator for an attribute no matter what kind.

This is an alias for attrib::<I>(name)?.iter::<T>().

source

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>>,

Update indirect attribute entries with the given closure.

Return a mutable reference to Self on success.

source

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.

source

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>().

source

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>().

source

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>().

source

fn attrib_clone_into_vec<'a, 'b, T, I: 'b + AttribIndex<Self>>( &'b self, name: &'a str ) -> Result<Vec<T>, Error>

Clone attribute data into a Vec<T>.

This works for direct and indirect attributes. Note that indirect attributes can be expensive to clone.

source

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>().

source

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.

source

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.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T: Real> Attrib for PointCloud<T>

source§

impl<T: Real> Attrib for PolyMesh<T>

source§

impl<T: Real> Attrib for TetMesh<T>

source§

impl<T: Real> Attrib for TetMeshExt<T>

source§

impl<T: Real> Attrib for LineMesh<T>

source§

impl<T: Real> Attrib for QuadMesh<T>

source§

impl<T: Real> Attrib for QuadMeshExt<T>

source§

impl<T: Real> Attrib for TriMesh<T>

source§

impl<T: Real> Attrib for TriMeshExt<T>

source§

impl<T: Real> Attrib for Mesh<T>