Skip to main content

SnapshotPlan

Struct SnapshotPlan 

Source
pub struct SnapshotPlan<'a> { /* private fields */ }
Expand description

Validated plan that can compute its encoded length and write itself.

SnapshotPlan performs all duplicate-kind, alignment, and count checks at construction. After construction, encoded_len and write_into are guaranteed to succeed for any caller-supplied buffer that is at least encoded_len() bytes long.

§Performance

Construction is O(s^2) for s sections (duplicate-kind check). encoded_len and write_into are O(s + total payload bytes).

Implementations§

Source§

impl<'a> SnapshotPlan<'a>

Source

pub fn new(sections: &'a [PendingSection<'a>]) -> Result<Self, PlanError>

Validates a slice of pending sections and constructs a plan.

§Errors

Returns PlanError when alignment is too large, too many sections are supplied, or duplicate kinds are present.

§Performance

This function is O(s^2) for s sections.

Source

pub const fn section_count(&self) -> usize

Returns the number of sections in this plan.

§Performance

This method is O(1).

Source

pub fn encoded_len(&self) -> Result<usize, PlanError>

Computes the total bytes the encoded snapshot will occupy.

§Errors

Returns PlanError::PayloadOverflow when offset arithmetic exceeds usize or u64 representable values.

§Performance

This function is O(s) for s sections.

Source

pub fn write_into(&self, out: &mut [u8]) -> Result<usize, PlanError>

Writes the encoded snapshot into out and returns the number of bytes written.

Padding bytes between the section table and each section payload are zero-filled deterministically; the resulting bytes are stable for any logical input.

§Errors

Returns PlanError::BufferTooSmall when out.len() is less than encoded_len or PlanError::PayloadOverflow when offset arithmetic overflows during the write walk.

§Performance

This function is O(s + total payload bytes).

Trait Implementations§

Source§

impl<'a> Clone for SnapshotPlan<'a>

Source§

fn clone(&self) -> SnapshotPlan<'a>

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<'a> Copy for SnapshotPlan<'a>

Source§

impl<'a> Debug for SnapshotPlan<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for SnapshotPlan<'a>

§

impl<'a> RefUnwindSafe for SnapshotPlan<'a>

§

impl<'a> Send for SnapshotPlan<'a>

§

impl<'a> Sync for SnapshotPlan<'a>

§

impl<'a> Unpin for SnapshotPlan<'a>

§

impl<'a> UnsafeUnpin for SnapshotPlan<'a>

§

impl<'a> UnwindSafe for SnapshotPlan<'a>

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.