Skip to main content

MapTypeExtra

Struct MapTypeExtra 

Source
pub struct MapTypeExtra {
Show 18 fields pub layout: MapLayout, pub key: u64, pub elem: u64, pub group: u64, pub hmap: Option<u64>, pub hasher: Option<u64>, pub group_size: Option<u64>, pub slot_size: Option<u64>, pub keys_off: Option<u64>, pub key_stride: Option<u64>, pub elems_off: Option<u64>, pub elem_stride: Option<u64>, pub elem_off: Option<u64>, pub key_size: Option<u8>, pub value_size: Option<u8>, pub bucket_size: Option<u16>, pub raw_flags: Option<u32>, pub flags: MapFlags,
}
Expand description

Parsed extra fields for a map type descriptor.

Fields absent from the descriptor’s MapLayout are None so callers can tell “this Go version does not record it” from a genuine zero.

Fields§

§layout: MapLayout

Which layout the descriptor was parsed with.

§key: u64

Virtual address of the key type descriptor.

§elem: u64

Virtual address of the element type descriptor.

§group: u64

Virtual address of the bucket (hmap) or slot-group (Swiss) type descriptor.

§hmap: Option<u64>

Virtual address of the hmap type descriptor (MapLayout::HmapWithHmapType only — Go 1.11 removed the field).

§hasher: Option<u64>

Virtual address of the key-hashing function. None for Go 1.11-1.13, which had no hasher field.

§group_size: Option<u64>

Size of a slot group in bytes (GroupSize). Swiss layouts only.

§slot_size: Option<u64>

Size of one key/elem slot (SlotSize). MapLayout::Swiss only — Go 1.27 replaced it with the explicit stride fields below.

§keys_off: Option<u64>

Offset of the keys array within a group (KeysOff). MapLayout::SwissSplitGroup only.

§key_stride: Option<u64>

Stride between consecutive keys (KeyStride). MapLayout::SwissSplitGroup only.

§elems_off: Option<u64>

Offset of the elements array within a group (ElemsOff). MapLayout::SwissSplitGroup only.

§elem_stride: Option<u64>

Stride between consecutive elements (ElemStride). MapLayout::SwissSplitGroup only.

§elem_off: Option<u64>

Offset from a key to its element within a slot (ElemOff). Present in both Swiss layouts.

§key_size: Option<u8>

Size of a key slot in bytes (KeySize). hmap layouts only.

§value_size: Option<u8>

Size of a value slot in bytes (ValueSize / elemsize). hmap layouts only.

§bucket_size: Option<u16>

Size of a bucket in bytes (BucketSize). hmap layouts only.

§raw_flags: Option<u32>

Raw flags word. None for the pre-1.12 layouts, which encoded the same properties as separate booleans. Bit meanings differ between the hmap and Swiss eras — prefer Self::flags, which normalizes them.

§flags: MapFlags

Semantic flags, normalized across all three encodings.

Implementations§

Source§

impl MapTypeExtra

Source

pub fn size(ps: u8, layout: MapLayout) -> usize

Binary size of the extra for the given pointer size and layout.

Every layout is pointer_fields * ptrSize followed by an 8-byte tail — either four small integers plus four booleans, or u8 + u8 + u16 + u32, or (Swiss) a u32 padded out to pointer alignment. That comes to pointers * ps + 8 on 64-bit and pointers * ps + 8 on 32-bit for the hmap layouts, and pointers * ps + 4 (+4) for the Swiss ones.

Source

pub fn parse(data: &[u8], ps: u8, layout: MapLayout) -> Option<Self>

Parse from data, which must start at the map type’s extra fields (i.e. just past the embedded abi.Type).

A MapLayout::Probe layout is resolved against these bytes first, so the returned Self::layout is always a concrete variant.

Returns None if the buffer is too small for the resolved layout.

Source

pub fn key_stride(&self) -> Option<u64>

Byte stride between consecutive keys in a bucket / group, however the descriptor’s layout happens to record it.

SwissSplitGroup states it directly as KeyStride; Swiss uses the key/elem SlotSize as the stride for both; the hmap layouts pack keys of KeySize contiguously in the bucket. None when the descriptor did not carry the value.

Source

pub fn elem_stride(&self) -> Option<u64>

Byte stride between consecutive elements, however the descriptor’s layout records it. See Self::key_stride.

Trait Implementations§

Source§

impl Clone for MapTypeExtra

Source§

fn clone(&self) -> MapTypeExtra

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for MapTypeExtra

Source§

impl Debug for MapTypeExtra

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for MapTypeExtra

Source§

impl PartialEq for MapTypeExtra

Source§

fn eq(&self, other: &MapTypeExtra) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for MapTypeExtra

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.