Trait gut::mesh::attrib::Attrib [−][src]
pub trait Attrib {
Show 30 methods
fn attrib_size<I>(&self) -> usize
where
I: AttribIndex<Self>;
fn attrib_dict<I>(
&self
) -> &HashMap<String, Attribute<I>, RandomState, Global>
where
I: AttribIndex<Self>;
fn attrib_dict_mut<I>(
&mut self
) -> &mut HashMap<String, Attribute<I>, RandomState, Global>
where
I: AttribIndex<Self>;
fn attrib_dict_and_cache_mut<I>(
&mut self
) -> (&mut HashMap<String, Attribute<I>, RandomState, Global>, Option<&mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>>)
where
I: AttribIndex<Self>;
fn add_attrib<T, I>(
&mut self,
name: &'a str,
def: T
) -> Result<&mut Attribute<I>, Error>
where
I: AttribIndex<Self>,
T: AttributeValue,
{ ... }
fn add_attrib_data<T, I>(
&mut self,
name: &'a str,
data: Vec<T, Global>
) -> Result<&mut Attribute<I>, Error>
where
I: AttribIndex<Self>,
T: AttributeValue + Default,
{ ... }
fn set_attrib<T, I>(
&mut self,
name: &'a str,
def: T
) -> Result<&mut Attribute<I>, Error>
where
I: AttribIndex<Self>,
T: AttributeValue,
{ ... }
fn set_attrib_data<T, I>(
&mut self,
name: &'a str,
data: &[T]
) -> Result<&mut Attribute<I>, Error>
where
I: AttribIndex<Self>,
T: AttributeValue + Default,
{ ... }
fn add_indirect_attrib<T, I>(
&mut self,
name: &'a str,
def: T
) -> Result<(&mut Attribute<I>, &mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>), Error>
where
I: AttribIndex<Self>,
T: AttributeValueHash,
{ ... }
fn set_indirect_attrib<T, I>(
&mut self,
name: &'a str,
def: T
) -> Result<(&mut Attribute<I>, &mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>), Error>
where
I: AttribIndex<Self>,
T: AttributeValueHash,
{ ... }
fn add_indirect_attrib_data<I>(
&mut self,
name: &'a str,
data: IndirectData
) -> Result<(&mut Attribute<I>, &mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>), Error>
where
I: AttribIndex<Self>,
{ ... }
fn set_indirect_attrib_data<I>(
&mut self,
name: &'a str,
data: IndirectData
) -> Result<(&mut Attribute<I>, &mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>), Error>
where
I: AttribIndex<Self>,
{ ... }
fn duplicate_attrib<T, I>(
&mut self,
name: &'a str,
new_name: &'b str
) -> Result<&mut Attribute<I>, Error>
where
I: AttribIndex<Self>,
T: Any + Clone,
{ ... }
fn remove_attrib<I>(&mut self, name: &str) -> Result<Attribute<I>, Error>
where
I: AttribIndex<Self>,
{ ... }
fn insert_attrib<I>(
&mut self,
name: &str,
attrib: Attribute<I>
) -> Result<Option<Attribute<I>>, Error>
where
I: AttribIndex<Self>,
{ ... }
fn attrib_or_add<T, I>(
&mut self,
name: &'a str,
def: T
) -> Result<&mut Attribute<I>, Error>
where
I: AttribIndex<Self>,
T: AttributeValue,
{ ... }
fn attrib_or_add_data<T, I>(
&mut self,
name: &'a str,
data: &[T]
) -> Result<&mut Attribute<I>, Error>
where
I: AttribIndex<Self>,
T: AttributeValue + Default,
{ ... }
fn attrib_or_add_indirect<T, I>(
&mut self,
name: &'a str,
def: T
) -> Result<(&mut Attribute<I>, &mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>), Error>
where
I: AttribIndex<Self>,
T: AttributeValueHash,
{ ... }
fn direct_attrib_iter<'b, T, I>(
&'b self,
name: &'a str
) -> Result<Iter<'b, T>, Error>
where
I: 'b + AttribIndex<Self>,
T: Any + Clone,
{ ... }
fn attrib_iter_mut<'b, T, I>(
&'b mut self,
name: &'a str
) -> Result<IterMut<'b, T>, Error>
where
I: 'b + AttribIndex<Self>,
T: Any + Clone,
{ ... }
fn attrib_iter<'b, T, I>(
&'b self,
name: &str
) -> Result<Box<dyn Iterator<Item = &'b T> + 'b, Global>, Error>
where
I: 'b + AttribIndex<Self>,
T: Any + Clone,
{ ... }
fn indirect_attrib_update_with<'b, T, I, F>(
&'b mut self,
name: &'a str,
f: F
) -> Result<(&'b mut Attribute<I>, &'b mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>), Error>
where
T: AttributeValueHash,
I: 'b + AttribIndex<Self>,
F: FnMut(usize, &Arc<T>) -> Option<Arc<T>>,
{ ... }
fn attrib_exists<I>(&self, name: &str) -> bool
where
I: AttribIndex<Self>,
{ ... }
fn attrib_check<T, I>(&self, name: &'a str) -> Result<&Attribute<I>, Error>
where
T: Any,
I: AttribIndex<Self>,
{ ... }
fn attrib_as_slice<'b, T, I>(
&'b self,
name: &'a str
) -> Result<&'b [T], Error>
where
T: 'static,
I: 'b + AttribIndex<Self>,
{ ... }
fn attrib_as_mut_slice<'b, T, I>(
&'b mut self,
name: &'a str
) -> Result<&'b mut [T], Error>
where
T: 'static,
I: 'b + AttribIndex<Self>,
{ ... }
fn attrib_clone_into_vec<'b, T, I>(
&'b self,
name: &'a str
) -> Result<Vec<T, Global>, Error>
where
I: 'b + AttribIndex<Self>,
T: AttributeValueHash,
{ ... }
fn direct_attrib_clone_into_vec<'b, T, I>(
&'b self,
name: &'a str
) -> Result<Vec<T, Global>, Error>
where
I: 'b + AttribIndex<Self>,
T: AttributeValue,
{ ... }
fn attrib<I>(&self, name: &'a str) -> Result<&Attribute<I>, Error>
where
I: AttribIndex<Self>,
{ ... }
fn attrib_mut<I>(
&mut self,
name: &'a str
) -> Result<&mut Attribute<I>, Error>
where
I: AttribIndex<Self>,
{ ... }
}
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
fn attrib_size<I>(&self) -> usize where
I: AttribIndex<Self>,
fn attrib_size<I>(&self) -> usize where
I: AttribIndex<Self>,
Get the size of the attribute at the appropriate mesh location determined by I
.
fn attrib_dict<I>(&self) -> &HashMap<String, Attribute<I>, RandomState, Global> where
I: AttribIndex<Self>,
fn attrib_dict<I>(&self) -> &HashMap<String, Attribute<I>, RandomState, Global> where
I: AttribIndex<Self>,
Read only access to the attribute dictionary.
fn attrib_dict_mut<I>(
&mut self
) -> &mut HashMap<String, Attribute<I>, RandomState, Global> where
I: AttribIndex<Self>,
fn attrib_dict_mut<I>(
&mut self
) -> &mut HashMap<String, Attribute<I>, RandomState, Global> where
I: AttribIndex<Self>,
Read and write access to the attribute dictionary.
fn attrib_dict_and_cache_mut<I>(
&mut self
) -> (&mut HashMap<String, Attribute<I>, RandomState, Global>, Option<&mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>>) where
I: AttribIndex<Self>,
fn attrib_dict_and_cache_mut<I>(
&mut self
) -> (&mut HashMap<String, Attribute<I>, RandomState, Global>, Option<&mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>>) where
I: AttribIndex<Self>,
Read and write access to the attribute dictionary along with a cache for indirect attribute values.
Provided methods
fn add_attrib<T, I>(
&mut self,
name: &'a str,
def: T
) -> Result<&mut Attribute<I>, Error> where
I: AttribIndex<Self>,
T: AttributeValue,
fn add_attrib<T, I>(
&mut self,
name: &'a str,
def: T
) -> Result<&mut Attribute<I>, Error> where
I: AttribIndex<Self>,
T: AttributeValue,
Add an attribute at the appropriate location with a given default.
fn add_attrib_data<T, I>(
&mut self,
name: &'a str,
data: Vec<T, Global>
) -> Result<&mut Attribute<I>, Error> where
I: AttribIndex<Self>,
T: AttributeValue + Default,
fn add_attrib_data<T, I>(
&mut self,
name: &'a str,
data: Vec<T, Global>
) -> Result<&mut Attribute<I>, Error> where
I: AttribIndex<Self>,
T: AttributeValue + Default,
Construct an attribute from a given data Vec<T>
. data
must have
exactly the right size for the attribute to be added successfully.
fn set_attrib<T, I>(
&mut self,
name: &'a str,
def: T
) -> Result<&mut Attribute<I>, Error> where
I: AttribIndex<Self>,
T: AttributeValue,
fn set_attrib<T, I>(
&mut self,
name: &'a str,
def: T
) -> Result<&mut Attribute<I>, Error> where
I: AttribIndex<Self>,
T: AttributeValue,
Sets the attribute to the specified default value whether or not it already exists.
fn set_attrib_data<T, I>(
&mut self,
name: &'a str,
data: &[T]
) -> Result<&mut Attribute<I>, Error> where
I: AttribIndex<Self>,
T: AttributeValue + Default,
fn set_attrib_data<T, I>(
&mut self,
name: &'a str,
data: &[T]
) -> Result<&mut Attribute<I>, Error> where
I: AttribIndex<Self>,
T: AttributeValue + Default,
Set an attribute to the given data slice. data
must have exactly the
right size for the attribute to be set successfully.
fn add_indirect_attrib<T, I>(
&mut self,
name: &'a str,
def: T
) -> Result<(&mut Attribute<I>, &mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>), Error> where
I: AttribIndex<Self>,
T: AttributeValueHash,
fn add_indirect_attrib<T, I>(
&mut self,
name: &'a str,
def: T
) -> Result<(&mut Attribute<I>, &mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>), Error> where
I: AttribIndex<Self>,
T: AttributeValueHash,
Add an indirect attribute at the appropriate location with a given default.
fn set_indirect_attrib<T, I>(
&mut self,
name: &'a str,
def: T
) -> Result<(&mut Attribute<I>, &mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>), Error> where
I: AttribIndex<Self>,
T: AttributeValueHash,
fn set_indirect_attrib<T, I>(
&mut self,
name: &'a str,
def: T
) -> Result<(&mut Attribute<I>, &mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>), Error> where
I: AttribIndex<Self>,
T: AttributeValueHash,
Sets the indirect attribute to the specified default value whether or not it already exists.
fn add_indirect_attrib_data<I>(
&mut self,
name: &'a str,
data: IndirectData
) -> Result<(&mut Attribute<I>, &mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>), Error> where
I: AttribIndex<Self>,
fn add_indirect_attrib_data<I>(
&mut self,
name: &'a str,
data: IndirectData
) -> Result<(&mut Attribute<I>, &mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>), Error> where
I: AttribIndex<Self>,
Construct an indirect attribute from a given IndirectData
. data
must have
exactly the right size for the attribute to be added successfully.
fn set_indirect_attrib_data<I>(
&mut self,
name: &'a str,
data: IndirectData
) -> Result<(&mut Attribute<I>, &mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>), Error> where
I: AttribIndex<Self>,
fn set_indirect_attrib_data<I>(
&mut self,
name: &'a str,
data: IndirectData
) -> Result<(&mut Attribute<I>, &mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>), Error> where
I: AttribIndex<Self>,
Set an indirect attribute to the given IndirectData
instance. data
must have
exactly the right size for the attribute to be set successfully.
fn duplicate_attrib<T, I>(
&mut self,
name: &'a str,
new_name: &'b str
) -> Result<&mut Attribute<I>, Error> where
I: AttribIndex<Self>,
T: Any + Clone,
fn duplicate_attrib<T, I>(
&mut self,
name: &'a str,
new_name: &'b str
) -> Result<&mut Attribute<I>, Error> where
I: AttribIndex<Self>,
T: Any + Clone,
Makes a copy of an existing attribute.
Return a mutable reference to the new attribute if successful.
fn remove_attrib<I>(&mut self, name: &str) -> Result<Attribute<I>, Error> where
I: AttribIndex<Self>,
fn remove_attrib<I>(&mut self, name: &str) -> Result<Attribute<I>, Error> where
I: AttribIndex<Self>,
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
.
fn insert_attrib<I>(
&mut self,
name: &str,
attrib: Attribute<I>
) -> Result<Option<Attribute<I>>, Error> where
I: AttribIndex<Self>,
fn insert_attrib<I>(
&mut self,
name: &str,
attrib: Attribute<I>
) -> Result<Option<Attribute<I>>, Error> where
I: AttribIndex<Self>,
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.
fn attrib_or_add<T, I>(
&mut self,
name: &'a str,
def: T
) -> Result<&mut Attribute<I>, Error> where
I: AttribIndex<Self>,
T: AttributeValue,
fn attrib_or_add<T, I>(
&mut self,
name: &'a str,
def: T
) -> Result<&mut Attribute<I>, Error> where
I: AttribIndex<Self>,
T: AttributeValue,
Retrieve the attribute with the given name and if it doesn’t exist, add a new one and set it to a given default value. In either case the mutable reference to the attribute is returned.
fn attrib_or_add_data<T, I>(
&mut self,
name: &'a str,
data: &[T]
) -> Result<&mut Attribute<I>, Error> where
I: AttribIndex<Self>,
T: AttributeValue + Default,
fn attrib_or_add_data<T, I>(
&mut self,
name: &'a str,
data: &[T]
) -> Result<&mut Attribute<I>, Error> where
I: AttribIndex<Self>,
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.
fn attrib_or_add_indirect<T, I>(
&mut self,
name: &'a str,
def: T
) -> Result<(&mut Attribute<I>, &mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>), Error> where
I: AttribIndex<Self>,
T: AttributeValueHash,
fn attrib_or_add_indirect<T, I>(
&mut self,
name: &'a str,
def: T
) -> Result<(&mut Attribute<I>, &mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>), Error> where
I: AttribIndex<Self>,
T: AttributeValueHash,
Retrieve the indirect attribute with the given name and if it doesn’t exist, add a new one and set it to a given default value. In either case the mutable reference to the attribute is returned.
fn direct_attrib_iter<'b, T, I>(
&'b self,
name: &'a str
) -> Result<Iter<'b, T>, Error> where
I: 'b + AttribIndex<Self>,
T: Any + Clone,
fn direct_attrib_iter<'b, T, I>(
&'b self,
name: &'a str
) -> Result<Iter<'b, T>, Error> where
I: 'b + AttribIndex<Self>,
T: Any + Clone,
Get the attribute iterator for a direct attribute.
fn attrib_iter_mut<'b, T, I>(
&'b mut self,
name: &'a str
) -> Result<IterMut<'b, T>, Error> where
I: 'b + AttribIndex<Self>,
T: Any + Clone,
fn attrib_iter_mut<'b, T, I>(
&'b mut self,
name: &'a str
) -> Result<IterMut<'b, T>, Error> where
I: 'b + AttribIndex<Self>,
T: Any + Clone,
Get the attribute mutable iterator for a direct attribute.
This is essentially an alias for attrib_mut(name).unwrap().direct_iter_mut::<T>()
.
Get the iterator for an attribute no matter what kind.
fn indirect_attrib_update_with<'b, T, I, F>(
&'b mut self,
name: &'a str,
f: F
) -> Result<(&'b mut Attribute<I>, &'b mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>), Error> where
T: AttributeValueHash,
I: 'b + AttribIndex<Self>,
F: FnMut(usize, &Arc<T>) -> Option<Arc<T>>,
fn indirect_attrib_update_with<'b, T, I, F>(
&'b mut self,
name: &'a str,
f: F
) -> Result<(&'b mut Attribute<I>, &'b mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>), Error> where
T: AttributeValueHash,
I: 'b + AttribIndex<Self>,
F: FnMut(usize, &Arc<T>) -> Option<Arc<T>>,
Update indirect attribute entries with the given closure.
Return a mutable reference to Self
on success.
fn attrib_exists<I>(&self, name: &str) -> bool where
I: AttribIndex<Self>,
fn attrib_exists<I>(&self, name: &str) -> bool where
I: AttribIndex<Self>,
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.
fn attrib_check<T, I>(&self, name: &'a str) -> Result<&Attribute<I>, Error> where
T: Any,
I: AttribIndex<Self>,
fn attrib_check<T, I>(&self, name: &'a str) -> Result<&Attribute<I>, Error> where
T: Any,
I: AttribIndex<Self>,
Determine if the given attribute is valid and exists at the given location.
fn attrib_as_slice<'b, T, I>(&'b self, name: &'a str) -> Result<&'b [T], Error> where
T: 'static,
I: 'b + AttribIndex<Self>,
fn attrib_as_slice<'b, T, I>(&'b self, name: &'a str) -> Result<&'b [T], Error> where
T: 'static,
I: 'b + AttribIndex<Self>,
Expose the underlying direct attribute as a slice.
fn attrib_as_mut_slice<'b, T, I>(
&'b mut self,
name: &'a str
) -> Result<&'b mut [T], Error> where
T: 'static,
I: 'b + AttribIndex<Self>,
fn attrib_as_mut_slice<'b, T, I>(
&'b mut self,
name: &'a str
) -> Result<&'b mut [T], Error> where
T: 'static,
I: 'b + AttribIndex<Self>,
Expose the underlying direct attribute as a mutable slice.
fn attrib_clone_into_vec<'b, T, I>(
&'b self,
name: &'a str
) -> Result<Vec<T, Global>, Error> where
I: 'b + AttribIndex<Self>,
T: AttributeValueHash,
fn attrib_clone_into_vec<'b, T, I>(
&'b self,
name: &'a str
) -> Result<Vec<T, Global>, Error> where
I: 'b + AttribIndex<Self>,
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.
fn direct_attrib_clone_into_vec<'b, T, I>(
&'b self,
name: &'a str
) -> Result<Vec<T, Global>, Error> where
I: 'b + AttribIndex<Self>,
T: AttributeValue,
fn direct_attrib_clone_into_vec<'b, T, I>(
&'b self,
name: &'a str
) -> Result<Vec<T, Global>, Error> where
I: 'b + AttribIndex<Self>,
T: AttributeValue,
Clone direct attribute data into a Vec<T>
.
Borrow the raw attribute from the attribute dictionary. From there you can use methods defined on the attribute itself.
fn attrib_mut<I>(&mut self, name: &'a str) -> Result<&mut Attribute<I>, Error> where
I: AttribIndex<Self>,
fn attrib_mut<I>(&mut self, name: &'a str) -> Result<&mut Attribute<I>, Error> where
I: AttribIndex<Self>,
Get the raw mutable attribute from the attribute dictionary. From there you can use methods defined on the attribute itself.