Skip to main content

SegmentDescriptor

Struct SegmentDescriptor 

Source
#[repr(C)]
pub struct SegmentDescriptor { pub offset: [u8; 4], pub count: [u8; 2], pub element_size: [u8; 2], }
Expand description

On-wire segment descriptor.

Each 8-byte entry describes one variable-length array within a segmented account. The descriptor lives in the segment table region, between the fixed prefix and the segment data.

Fields§

§offset: [u8; 4]

Byte offset from the start of the account data to the first element of this segment.

§count: [u8; 2]

Number of elements currently stored in this segment.

§element_size: [u8; 2]

Size of each element in bytes.

Implementations§

Source§

impl SegmentDescriptor

Source

pub const fn new(offset: u32, count: u16, element_size: u16) -> Self

Create a new descriptor.

Source

pub const fn offset(&self) -> u32

Read the byte offset.

Source

pub const fn count(&self) -> u16

Read the element count.

Source

pub const fn element_size(&self) -> u16

Read the element size.

Source

pub const fn data_len(&self) -> usize

Total byte footprint of this segment’s data (count × element_size).

Source

pub const fn byte_range(&self) -> Option<(usize, usize)>

Byte range [offset .. offset + data_len). Returns None on overflow.

Trait Implementations§

Source§

impl Clone for SegmentDescriptor

Source§

fn clone(&self) -> SegmentDescriptor

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for SegmentDescriptor

Source§

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

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

impl FixedLayout for SegmentDescriptor

Source§

const SIZE: usize = SEGMENT_DESC_SIZE

The exact byte size of this type on-chain.
Source§

impl PartialEq for SegmentDescriptor

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for SegmentDescriptor

Source§

impl Eq for SegmentDescriptor

Source§

impl Pod for SegmentDescriptor

Source§

impl StructuralPartialEq for SegmentDescriptor

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.