Struct gut::mesh::attrib::Attribute [−][src]
pub struct Attribute<I> {
pub data: AttributeData,
// some fields omitted
}
Expand description
Mesh attribute with an associated topology I
.
This stores values that can be attached to mesh elements.
Fields
data: AttributeData
Underlying attribute data.
This can be used to manipulate attribute values or their references directly.
Implementations
This type wraps a DataVec
to store attribute data. Having the type parameter I
allows
the compiler verify that attributes are being indexed correctly.
Construct a direct attribute with a given size.
Construct an indirect attribute with a given size.
pub fn direct_from_vec<T>(vec: Vec<T, Global>) -> Attribute<I> where
T: AttributeValue + Default,
pub fn direct_from_vec<T>(vec: Vec<T, Global>) -> Attribute<I> where
T: AttributeValue + Default,
Construct a direct attribute from a given Vec<T>
of data reusing the space already
allocated by the Vec
.
pub fn indirect_from_vec<T>(
vec: Vec<T, Global>,
cache: &mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>
) -> Attribute<I> where
T: AttributeValueHash + Default,
pub fn indirect_from_vec<T>(
vec: Vec<T, Global>,
cache: &mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>
) -> Attribute<I> where
T: AttributeValueHash + Default,
Construct an indirect attribute from a given Vec<T>
of data, while saving any repeated
values in the given cache.
Construct an indirect attribute from a given IndirectData
instance. It is assumed that
the included data is already cached correctly in the associated cache.
Produce a slice to the underlying direct attribute data.
Produce a mutable slice to the underlying direct attribute data.
Construct a new empty attribute with the same buffer type, default element and topology as
self
.
pub fn duplicate_with(
&self,
duplicate_data: impl FnOnce(&mut VecDyn<dyn HasAttributeValue + 'static>, Slice<'_, dyn HasAttributeValue + 'static>)
) -> Attribute<I>
pub fn duplicate_with(
&self,
duplicate_data: impl FnOnce(&mut VecDyn<dyn HasAttributeValue + 'static>, Slice<'_, dyn HasAttributeValue + 'static>)
) -> Attribute<I>
Construct a new attribute with the same buffer type, default element and topology type as
self
.
The data within the newly created attribute is expected to be initialized with the given
function init
, which takes the output DataSliceMut
for the new attribute and the existing
DataSlice
from self
.
pub fn duplicate_with_len(
&self,
len: usize,
init: impl FnOnce(SliceMut<'_, AttributeValueVTable>, Slice<'_, AttributeValueVTable>)
) -> Attribute<I>
pub fn duplicate_with_len(
&self,
len: usize,
init: impl FnOnce(SliceMut<'_, AttributeValueVTable>, Slice<'_, AttributeValueVTable>)
) -> Attribute<I>
Construct a new attribute with the same buffer type, default element and topology type as
self
.
The attribute is first initialized with the default value by allocating len
default
elements. Then the newly created buffer is expected to be modified by the init
function.
Construct a new empty attribute with the same buffer type and default element as self
.
In contrast to duplicate_empty
this function allows the new attribute to correspond with a
different topology.
pub fn promote_with<J>(
&self,
promote_data: impl FnOnce(&mut VecDyn<dyn HasAttributeValue + 'static>, Slice<'_, dyn HasAttributeValue + 'static>)
) -> Attribute<J>
pub fn promote_with<J>(
&self,
promote_data: impl FnOnce(&mut VecDyn<dyn HasAttributeValue + 'static>, Slice<'_, dyn HasAttributeValue + 'static>)
) -> Attribute<J>
Construct a new attribute with the same buffer type and default element as self
.
pub fn promote_with_len<J>(
&self,
len: usize,
init: impl FnOnce(SliceMut<'_, AttributeValueVTable>, Slice<'_, AttributeValueVTable>)
) -> Attribute<J>
pub fn promote_with_len<J>(
&self,
len: usize,
init: impl FnOnce(SliceMut<'_, AttributeValueVTable>, Slice<'_, AttributeValueVTable>)
) -> Attribute<J>
Construct a new attribute with the same buffer type and default element as self
.
The attribute is first initialized with the default value by allocating len
default
elements. Then the newly created buffer is expected to be modified by the init
function.
Construct a direct attribute from a given slice of data, by copying the data.
pub fn indirect_from_slice<T>(
data: &[T],
cache: &mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>
) -> Attribute<I> where
T: AttributeValueHash + Default,
pub fn indirect_from_slice<T>(
data: &[T],
cache: &mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>
) -> Attribute<I> where
T: AttributeValueHash + Default,
Construct an indirect attribute from a given slice of data, by copying the data.
Get the type data stored within this attribute
Get the mutable typed data stored within this attribute
Produce an iterator over the underlying data elements.
Produce an iterator over the underlying data elements for a direct attribute.
Produce an iterator over the underlying data elements for an indirect attribute.
Produce a mutable iterator over the underlying data elements for a direct attribute.
pub fn indirect_update_with<T, F>(
&mut self,
f: F,
cache: &mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>
) -> Result<&mut Attribute<I>, Error> where
T: AttributeValueHash,
F: FnMut(usize, &Arc<T>) -> Option<Arc<T>>,
pub fn indirect_update_with<T, F>(
&mut self,
f: F,
cache: &mut HashSet<Value<MaybeUninit<usize>, AttributeValueHashVTable>, RandomState, Global>
) -> Result<&mut Attribute<I>, Error> where
T: AttributeValueHash,
F: FnMut(usize, &Arc<T>) -> Option<Arc<T>>,
Iterate over all the value in this attribute and update them as needed.
This function takes a closure which takes an index and a smart pointer to the stored value and produces an optional new value. The new value is then used to update the attribute using the provided cache.
Convert the data stored by this attribute into a vector of the same size.
Convert the data stored by this direct attribute into a vector of the same size.
Number of elements stored by this attribute. This is the same as the number of elements in the associated topology.
Get a reference to the internal data as a DataSlice
.
Get a mutable reference to the internal data as a DataSliceMut
.
Convert this attribute into the underlying buffer. This consumes the attribute.
Extend this attribute by n
elements. Effectively, this function appends the default
element n
number of times to this attribute.
Rotate this attribute in-place such that the first mid
elements of the underlying buffer
move to the end while the last self.len() - mid
elements move to the front. After
calling rotate_left
, the element previously at index mid
will become the first element
in the slice.
Rotate this attribute in-place such that the first self.len() - k
elements of the
underlying buffer move to the end while the last k
elements move to the front. After
calling rotate_right
, the element previously at index self.len() - k
will become the
first element in the slice.
Get a reference to the default element.
Get i
’th attribute value.
Get a const
reference to the i
’th attribute value.
Get a mutable reference to the i
’th direct attribute value.
This function works only on direct attributes. Indirect attributes cannot be modified via mutable references, since they employ a special caching mechanism which aliases each stored element.
Get i
’th attribute value.
Get a const
reference to the i
’th attribute value.
Get a mutable reference to the i
’th direct attribute value.
This function works only on direct attributes. Indirect attributes cannot be modified via mutable references, since they employ a special caching mechanism which aliases each stored element.
Get i
’th attribute value.
Get a const
reference to the i
’th attribute value.
Get a mutable reference to the i
’th direct attribute value.
This function works only on direct attributes. Indirect attributes cannot be modified via mutable references, since they employ a special caching mechanism which aliases each stored element.
Get i
’th attribute value.
Get a const
reference to the i
’th attribute value.
Get a mutable reference to the i
’th direct attribute value.
This function works only on direct attributes. Indirect attributes cannot be modified via mutable references, since they employ a special caching mechanism which aliases each stored element.
Get i
’th attribute value.
Get a const
reference to the i
’th attribute value.
Get a mutable reference to the i
’th direct attribute value.
This function works only on direct attributes. Indirect attributes cannot be modified via mutable references, since they employ a special caching mechanism which aliases each stored element.
Get i
’th attribute value.
Get a const
reference to the i
’th attribute value.
Get a mutable reference to the i
’th direct attribute value.
This function works only on direct attributes. Indirect attributes cannot be modified via mutable references, since they employ a special caching mechanism which aliases each stored element.
Get i
’th attribute value.
Get a const
reference to the i
’th attribute value.
Get a mutable reference to the i
’th direct attribute value.
This function works only on direct attributes. Indirect attributes cannot be modified via mutable references, since they employ a special caching mechanism which aliases each stored element.
Get i
’th attribute value.
Get a const
reference to the i
’th attribute value.
Get a mutable reference to the i
’th direct attribute value.
This function works only on direct attributes. Indirect attributes cannot be modified via mutable references, since they employ a special caching mechanism which aliases each stored element.
Get i
’th attribute value.
Get a const
reference to the i
’th attribute value.
Get a mutable reference to the i
’th direct attribute value.
This function works only on direct attributes. Indirect attributes cannot be modified via mutable references, since they employ a special caching mechanism which aliases each stored element.
Get i
’th attribute value.
Get a const
reference to the i
’th attribute value.
Get a mutable reference to the i
’th direct attribute value.
This function works only on direct attributes. Indirect attributes cannot be modified via mutable references, since they employ a special caching mechanism which aliases each stored element.
Get i
’th attribute value.
Get a const
reference to the i
’th attribute value.
Get a mutable reference to the i
’th direct attribute value.
This function works only on direct attributes. Indirect attributes cannot be modified via mutable references, since they employ a special caching mechanism which aliases each stored element.
Get i
’th attribute value.
Get a const
reference to the i
’th attribute value.
Get a mutable reference to the i
’th direct attribute value.
This function works only on direct attributes. Indirect attributes cannot be modified via mutable references, since they employ a special caching mechanism which aliases each stored element.
Get i
’th attribute value.
Get a const
reference to the i
’th attribute value.
Get a mutable reference to the i
’th direct attribute value.
This function works only on direct attributes. Indirect attributes cannot be modified via mutable references, since they employ a special caching mechanism which aliases each stored element.
Get i
’th attribute value.
Get a const
reference to the i
’th attribute value.
Get a mutable reference to the i
’th direct attribute value.
This function works only on direct attributes. Indirect attributes cannot be modified via mutable references, since they employ a special caching mechanism which aliases each stored element.
Get i
’th attribute value.
Get a const
reference to the i
’th attribute value.
Get a mutable reference to the i
’th direct attribute value.
This function works only on direct attributes. Indirect attributes cannot be modified via mutable references, since they employ a special caching mechanism which aliases each stored element.
Get i
’th attribute value.
Get a const
reference to the i
’th attribute value.
Get a mutable reference to the i
’th direct attribute value.
This function works only on direct attributes. Indirect attributes cannot be modified via mutable references, since they employ a special caching mechanism which aliases each stored element.
Get i
’th attribute value.
Get a const
reference to the i
’th attribute value.
Get a mutable reference to the i
’th direct attribute value.
This function works only on direct attributes. Indirect attributes cannot be modified via mutable references, since they employ a special caching mechanism which aliases each stored element.
Trait Implementations
Auto Trait Implementations
impl<I> RefUnwindSafe for Attribute<I> where
I: RefUnwindSafe,
impl<I> UnwindSafe for Attribute<I> where
I: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<T> CloneBytes for T where
T: 'static + Clone,
impl<T> CloneBytes for T where
T: 'static + Clone,
pub unsafe fn clone_bytes(
src: &[MaybeUninit<u8>]
) -> Box<[MaybeUninit<u8>], Global>
pub unsafe fn clone_from_bytes(
dst: &mut [MaybeUninit<u8>],
src: &[MaybeUninit<u8>]
)
pub unsafe fn clone_into_raw_bytes(
src: &[MaybeUninit<u8>],
dst: &mut [MaybeUninit<u8>]
)
impl<T> DebugBytes for T where
T: 'static + Debug,
impl<T> DebugBytes for T where
T: 'static + Debug,
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
pub unsafe fn drop_bytes(bytes: &mut [MaybeUninit<u8>])
type Output = <I as GetIndex<'a, S>>::Output
fn at(&self, idx: I) -> Self::Output
fn at(&self, idx: I) -> Self::Output
Return a value at the given index. This is provided as the checked
version of get
that will panic if the equivalent get
call is None
,
which typically means that the given index is out of bounds. Read more
unsafe fn at_unchecked(&self, idx: I) -> Self::Output
unsafe fn at_unchecked(&self, idx: I) -> Self::Output
Return a value at the given index. This is provided as the unchecked
version of get
that has undefined behavior when the index is out of bounds. Read more
type Output = <I as IsolateIndex<S>>::Output
pub unsafe fn isolate_unchecked(self, idx: I) -> <S as Isolate<I>>::Output
pub fn try_isolate(self, idx: I) -> Option<<S as Isolate<I>>::Output>
impl<T> PartialEqBytes for T where
T: 'static + PartialEq<T>,
impl<T> PartialEqBytes for T where
T: 'static + PartialEq<T>,
pub unsafe fn eq_bytes(a: &[MaybeUninit<u8>], b: &[MaybeUninit<u8>]) -> bool
impl<T, N> PushArrayToVec<N> for T where
T: Clone,
N: Array<T>,
impl<T, N> PushArrayToVec<N> for T where
T: Clone,
N: Array<T>,
pub fn push_to_vec(element: <N as Array<T>>::Array, set: &mut Vec<T, Global>)
pub fn push_to_vec(element: <N as Array<T>>::Array, set: &mut Vec<T, Global>)
This method tells this type how it can be pushed to a Vec
as an array.
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.