Ointer

Struct Ointer 

Source
pub struct Ointer<T: ?Sized, const A: u8, const S: bool, const V: u8> { /* private fields */ }
Expand description

A pointer we stole the high bits off

T: type pointed to. A: number of bits to steal based on the alignment requirements of T. S: whether to steal the sign bit. V: number of bits to steal from unused virtual address space.

Implementations§

Source§

impl<T: ?Sized, const A: u8, const S: bool, const V: u8> Ointer<T, A, S, V>

Source

pub unsafe fn new(ptr: *mut T) -> Self

Creates a new Ointer from a presumed legitimate pointer.

§Safety
  • T’s alignment must enable stealing A bits.
  • The high bits (sign upwards) must match a stack pointer’s high bits.
  • If compiling for a 64bit arch, V must be at most 25.
  • If compiling for a non-64bit arch, V must be 0.

These invariants are checked with debug_assert only, hence unsafe. The usual caveats of pointers apply.

Source

pub unsafe fn new_stealing(ptr: *mut T, bits: usize) -> Self

Constructor that enables stealing bits.

§Safety

Same as new

Source

pub fn stolen(self) -> usize

Returns the stolen bits in the high pos.

Source

pub fn steal(self, bits: usize) -> Self

Takes a value from the high bits of the provided usize and steals them from the ointer.

Source

pub fn as_ptr(self) -> *mut T

Get the pointer without the stolen bits

Source

pub fn raw(self) -> usize

Direct access to the underlying data. The pointer it returns may not be valid.

Trait Implementations§

Source§

impl<T: ?Sized, const A: u8, const S: bool, const V: u8> Clone for Ointer<T, A, S, V>

Source§

fn clone(&self) -> Self

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<T: Debug + ?Sized, const A: u8, const S: bool, const V: u8> Debug for Ointer<T, A, S, V>

Source§

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

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

impl<T: ?Sized, const A: u8, const S: bool, const V: u8> Hash for Ointer<T, A, S, V>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: ?Sized, const A: u8, const S: bool, const V: u8> PartialEq for Ointer<T, A, S, V>

Source§

fn eq(&self, other: &Self) -> 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<T: ?Sized, const A: u8, const S: bool, const V: u8> Copy for Ointer<T, A, S, V>

Source§

impl<T: ?Sized, const A: u8, const S: bool, const V: u8> Eq for Ointer<T, A, S, V>

Auto Trait Implementations§

§

impl<T, const A: u8, const S: bool, const V: u8> Freeze for Ointer<T, A, S, V>
where T: ?Sized,

§

impl<T, const A: u8, const S: bool, const V: u8> RefUnwindSafe for Ointer<T, A, S, V>
where T: RefUnwindSafe + ?Sized,

§

impl<T, const A: u8, const S: bool, const V: u8> !Send for Ointer<T, A, S, V>

§

impl<T, const A: u8, const S: bool, const V: u8> !Sync for Ointer<T, A, S, V>

§

impl<T, const A: u8, const S: bool, const V: u8> Unpin for Ointer<T, A, S, V>
where T: ?Sized,

§

impl<T, const A: u8, const S: bool, const V: u8> UnwindSafe for Ointer<T, A, S, V>
where T: RefUnwindSafe + ?Sized,

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.