pub struct FieldLayout {
pub atoms: Vec<AtomLayout>,
}Expand description
Flattened FAB atom sequence and ZKIR field-element geometry for a TypeDescriptor.
Fields§
§atoms: Vec<AtomLayout>Ordered sequence of FAB alignment atoms comprising this type.
Implementations§
Source§impl FieldLayout
impl FieldLayout
Sourcepub fn from_field_type(field_type: FieldType) -> Self
pub fn from_field_type(field_type: FieldType) -> Self
Derive the flattened layout of a FieldType.
Sourcepub fn from_descriptor(descriptor: &TypeDescriptor) -> Option<Self>
pub fn from_descriptor(descriptor: &TypeDescriptor) -> Option<Self>
Derive the flattened FAB / ZKIR layout of a TypeDescriptor.
Returns None for non-flat container types (Map, Set, List,
MerkleTree, HistoricMerkleTree), Unknown, or invalid Uint bounds.
Sourcepub fn atom_count(&self) -> usize
pub fn atom_count(&self) -> usize
Number of FAB alignment atoms.
Sourcepub fn field_slots(&self) -> usize
pub fn field_slots(&self) -> usize
Total number of native BLS12-381 field elements occupied by this type.
Sourcepub fn binary_len(&self) -> usize
pub fn binary_len(&self) -> usize
Total binary hash representation length in bytes.
Sourcepub fn needs_chunk_reordering(&self) -> bool
pub fn needs_chunk_reordering(&self) -> bool
Returns true if any atom in this layout is a multi-chunk Bytes<N>
(N > 31) whose field-element order differs between FAB and ZKIR v3.
Sourcepub fn reorder_field_slots<T: Clone>(
&self,
slots: &[T],
from: ChunkOrder,
to: ChunkOrder,
) -> Option<Vec<T>>
pub fn reorder_field_slots<T: Clone>( &self, slots: &[T], from: ChunkOrder, to: ChunkOrder, ) -> Option<Vec<T>>
Convert a flat slice of field-element slots for this layout between
ChunkOrder::MsbFirst (FAB) and ChunkOrder::LsbFirst (ZKIR v3).
Reverses the sub-slice belonging to each multi-chunk Bytes<N> (N > 31)
atom when from != to, while leaving single-slot atoms (including the two
separate limb atoms of foreign fields) in place.
Returns None if slots.len() != self.field_slots().
Trait Implementations§
Source§impl Clone for FieldLayout
impl Clone for FieldLayout
Source§impl Debug for FieldLayout
impl Debug for FieldLayout
impl Eq for FieldLayout
Source§impl PartialEq for FieldLayout
impl PartialEq for FieldLayout
impl StructuralPartialEq for FieldLayout
Auto Trait Implementations§
impl Forget for FieldLayout
impl Freeze for FieldLayout
impl Move for FieldLayout
impl RefUnwindSafe for FieldLayout
impl Send for FieldLayoutwhere
RawVecInner: Send,
impl Sync for FieldLayoutwhere
RawVecInner: Sync,
impl Unpin for FieldLayout
impl UnsafeUnpin for FieldLayout
impl UnwindSafe for FieldLayoutwhere
RawVecInner: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.