PackedRef

Struct PackedRef 

Source
pub struct PackedRef<'a, T, C: PtrCfg, D: Packable>(/* private fields */);
Expand description

A type safe reference to a packed pointer.

Equivalent to &T where T is the type of the pointer.

Implementations§

Source§

impl<'a, T, C: PtrCfg, D: Packable> PackedRef<'a, T, C, D>

Source

pub fn new(ptr: &'a T, data: D, cfg: C) -> Result<Self, PackedPtrError>

Creates a new PackedRef from a reference and some data.

§Errors
Source

pub unsafe fn new_unchecked(ptr: &'a T, data: D) -> Self

Creates a new PackedRef from a reference and some data without performing any safety checks.

§Safety

This function is unsafe because the caller assumes the responsibility of ensuring that the provided ptr and data are valid and that they are compatible with the configuration.

References are always aligned, therefore ptr should always be valid, but if the ptr of the system is incompatible with the configuration, then the reference will be corrupted, resulting in UB.

Also, if the data is too big to fit in the pointer, undefined behavior may occur.

§Arguments
  • ptr: A reference to a T
  • data: The data to be packed into the pointer.
§Returns

A new PackedRef with the given ptr and data.

Source

pub fn data(self) -> D

Returns the packed data value of the Packed Pointer.

Source

pub fn get(self) -> (&'a T, D)

Returns a tuple containing the reference and the packed data value.

Source

pub fn set_data(&mut self, data: D)

Sets the packed data value of the pointer.

§Arguments
  • data: The data to pack into the pointer.

Trait Implementations§

Source§

impl<T, C: PtrCfg, D: Packable> Clone for PackedRef<'_, T, C, D>

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, C: PtrCfg, D: Packable + Debug> Debug for PackedRef<'_, T, C, D>

Source§

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

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

impl<T, C: PtrCfg, D: Packable> Deref for PackedRef<'_, T, C, D>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T, C: PtrCfg, D: Packable> Pointer for PackedRef<'_, T, C, D>

Source§

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

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

impl<T, C: PtrCfg, D: Packable> Copy for PackedRef<'_, T, C, D>

Auto Trait Implementations§

§

impl<'a, T, C, D> Freeze for PackedRef<'a, T, C, D>

§

impl<'a, T, C, D> RefUnwindSafe for PackedRef<'a, T, C, D>

§

impl<'a, T, C, D> !Send for PackedRef<'a, T, C, D>

§

impl<'a, T, C, D> !Sync for PackedRef<'a, T, C, D>

§

impl<'a, T, C, D> Unpin for PackedRef<'a, T, C, D>
where D: Unpin, C: Unpin,

§

impl<'a, T, C, D> UnwindSafe for PackedRef<'a, T, C, D>

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.