Skip to main content

RawSequence

Struct RawSequence 

Source
pub struct RawSequence { /* private fields */ }
Expand description

A sequence that stores heterogeneous values with proper alignment.

The RawSequence provides a memory-efficient way to store heterogeneous values while maintaining proper alignment requirements for each type. It uses an internal buffer that aligns values according to their type’s requirements, up to a maximum alignment of 4096 bytes.

Implementations§

Source§

impl RawSequence

Source

pub fn new() -> RawSequence

Creates a new empty RawSequence. The sequence is initialized with a 4096-byte aligned buffer.

Source

pub fn push<T>(&mut self, value: T)

Pushes a value onto the sequence.

The value is stored at an address that satisfies its alignment requirements. Automatically grows the internal buffer if needed.

§Panics

Panics if the type’s alignment requirement exceeds 4096 bytes.

Source

pub unsafe fn drop_in_place<T>(&mut self, p: usize) -> usize

Drops a value in-place at the specified position.

§Safety
  • The position must point to a valid value of type T
  • The caller must ensure that the value is actually of type T

Returns the position immediately after the dropped value.

Source

pub unsafe fn next<T>(&self, p: usize) -> (&T, usize)

Retrieves a reference to the next value at the specified position.

§Safety
  • The position must point to a valid value of type T
  • The caller must ensure that the value is actually of type T

Returns a tuple containing:

  • A reference to the value
  • The position immediately after the value
Source

pub fn len(&self) -> usize

Returns the number of bytes in the RawSequence, also referred to as its ‘length’.

Source

pub fn is_empty(&self) -> bool

Returns true if the RawSequence has no elements.

Trait Implementations§

Source§

impl Default for RawSequence

Source§

fn default() -> RawSequence

Returns the “default value” for a type. Read more

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.