Skip to main content

Section

Struct Section 

Source
pub struct Section<'view> { /* private fields */ }
Expand description

Borrowed view of one validated section in a snapshot.

A Section carries the section’s byte payload along with its declared metadata. Payload bytes are bounds- and overlap-checked at snapshot open time. Typed-slice access via Section::try_as_slice verifies the actual borrowed pointer’s alignment at the call site.

§Performance

All methods are O(1) or O(payload.len()) for typed conversions.

Implementations§

Source§

impl<'view> Section<'view>

Source

pub const fn kind(&self) -> u32

Returns the section’s opaque kind identifier.

§Performance

This method is O(1).

Source

pub const fn version(&self) -> u32

Returns the section’s opaque version identifier.

§Performance

This method is O(1).

Source

pub const fn declared_alignment(&self) -> usize

Returns the alignment the producer declared for this payload.

This is metadata recorded at build time, not a guarantee about the actual borrowed pointer. Callers that intend to interpret the payload as a typed slice should prefer Section::try_as_slice, which checks the actual payload pointer.

§Performance

This method is O(1).

Source

pub const fn bytes(&self) -> &'view [u8]

Returns the section’s borrowed payload bytes.

§Performance

This method is O(1).

Source

pub fn try_as_slice<T>(&self) -> Result<&'view [T], SectionViewError>

Borrows the payload as a typed slice of T.

Errors if (a) payload.len() is not a multiple of core::mem::size_of::<T>() or (b) the payload’s actual base address does not satisfy core::mem::align_of::<T>(). The producer’s declared alignment_log2 is not consulted; the actual borrowed pointer is checked directly so that mmap’d or sub-sliced inputs cannot bypass the check.

§Errors

Returns SectionViewError when the payload cannot be borrowed as &[T] without copying.

§Performance

This method is O(1) modulo the bounds and alignment checks; it performs no allocation and no per-element work.

Trait Implementations§

Source§

impl<'view> Clone for Section<'view>

Source§

fn clone(&self) -> Section<'view>

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<'view> Debug for Section<'view>

Source§

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

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

impl<'view> Copy for Section<'view>

Auto Trait Implementations§

§

impl<'view> Freeze for Section<'view>

§

impl<'view> RefUnwindSafe for Section<'view>

§

impl<'view> Send for Section<'view>

§

impl<'view> Sync for Section<'view>

§

impl<'view> Unpin for Section<'view>

§

impl<'view> UnsafeUnpin for Section<'view>

§

impl<'view> UnwindSafe for Section<'view>

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, 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.