Skip to main content

VPtr

Struct VPtr 

Source
pub struct VPtr {
    pub alloc_id: u8,
    pub offset: u32,
    pub size: u32,
}
Expand description

Fat pointer for verified heap operations.

Contains allocation metadata for bounds checking without borrowing the heap.

Fields§

§alloc_id: u8

Which allocation this points into.

§offset: u32

Current byte offset within the allocation.

§size: u32

Total size of the allocation (for bounds checking).

Implementations§

Source§

impl VPtr

Source

pub const fn new(alloc_id: u8, size: u32) -> Self

Create a new pointer to the start of an allocation.

Source

pub fn offset(self, n: usize) -> Self

Compute a new pointer at an offset from this one.

§Panics

Panics if the resulting offset would exceed the allocation size.

Source

pub const fn offset_bytes(self) -> usize

Returns the current offset within the allocation.

Source

pub const fn alloc_id(self) -> u8

Returns the allocation ID.

Source

pub const fn alloc_size(self) -> usize

Returns the total size of the allocation.

Source

pub const fn is_at_start(self) -> bool

Check if this pointer is at the start of its allocation.

Source

pub const fn remaining(self) -> usize

Returns the number of bytes remaining from this offset to end of allocation.

Trait Implementations§

Source§

impl Clone for VPtr

Source§

fn clone(&self) -> VPtr

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 VPtr

Source§

impl Debug for VPtr

Source§

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

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

impl Eq for VPtr

Source§

impl IPtr for VPtr

Source§

unsafe fn byte_add(self, n: usize) -> Self

Compute a new pointer at a byte offset from this one. Read more
Source§

impl PartialEq for VPtr

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 StructuralPartialEq for VPtr

Auto Trait Implementations§

§

impl Freeze for VPtr

§

impl RefUnwindSafe for VPtr

§

impl Send for VPtr

§

impl Sync for VPtr

§

impl Unpin for VPtr

§

impl UnsafeUnpin for VPtr

§

impl UnwindSafe for VPtr

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

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.