Skip to main content

PointerDereferencer

Struct PointerDereferencer 

Source
pub struct PointerDereferencer<P> { /* private fields */ }
Expand description

Updatable, Getter, Settable, and TimeGetter are passed through Box, Rc<RefCell<T>>, Arc<RwLock<T>>, and Arc<Mutex<T>>, but this cannot be done safely for references involving raw pointer dereferencing. This is a wrapper struct that provides this functionality for *mut T, *const RwLock<T>, and *const Mutex<T>. It’s constructor is unsafe fn, so this is considered sound.

Implementations§

Source§

impl<P> PointerDereferencer<P>

Source

pub const unsafe fn new(pointer: P) -> Self

The constructor for PointerDereferencer. Although this constructor itself does not run any unsafe code, it is unsafe fn since this type inherently performs unsafe functions. See the type documentation for more information.

Although it is technically possible to construct a PointerDereferencer<P> where P is not a raw pointer, there is no valid reason to do so and the object would be entirely useless.

Source

pub fn into_ptr(self) -> P

Returns the inner pointer that the wrapper contains by consuming it. Due to the fact that pointers are Copy, copy_ptr, which does not consume self and is const fn, is preferred in almost all cases however.

Source§

impl<P: Clone> PointerDereferencer<P>

Source

pub fn clone_ptr(&self) -> P

Clones and returns the inner pointer that the wrapper contains. Due to the fact that pointers are Copy, copy_ptr is nearly always preferred both for clarity and because it is const fn however.

Source§

impl<P: Copy> PointerDereferencer<P>

Source

pub const fn copy_ptr(&self) -> P

This function is be identical to clone_ptr when P: Copy. However, copy_ptr should be preferred where possible because, unlike clone_inner, it is const fn. It is also clearer that the clone is very light.

Source§

impl<T> PointerDereferencer<*mut T>

These functions get a PointerDereferencer<*mut dyn Trait> from a PointerDereferencer<*mut T> where T: Trait. Because raw pointers are Copy, they only require &self and do not consume the original PointerDereferencer. Unfortunately T currently must be Sized due to language limitations.

Source

pub const fn as_dyn_updatable<E: Clone + Debug>( &self, ) -> PointerDereferencer<*mut dyn Updatable<E> + '_>
where T: Updatable<E>,

Source

pub const fn as_dyn_getter<U, E: Clone + Debug>( &self, ) -> PointerDereferencer<*mut dyn Getter<U, E> + '_>
where T: Getter<U, E>,

Source

pub const fn as_dyn_settable<U, E: Clone + Debug>( &self, ) -> PointerDereferencer<*mut dyn Settable<U, E> + '_>
where T: Settable<U, E>,

Source

pub const fn as_dyn_time_getter<E: Clone + Debug>( &self, ) -> PointerDereferencer<*mut dyn TimeGetter<E> + '_>
where T: TimeGetter<E>,

Source

pub const fn as_dyn_chronology<U>( &self, ) -> PointerDereferencer<*mut dyn Chronology<U> + '_>
where T: Chronology<U>,

Source§

impl<T> PointerDereferencer<*const RwLock<T>>

These functions get a PointerDereferencer<*const RwLock<dyn Trait>> from a PointerDereferencer<*const RwLock<T>> where T: Trait. Because raw pointers are Copy, they only require &self and do not consume the original PointerDereferencer. Unfortunately T currently must be Sized due to language limitations.

Source

pub const fn as_dyn_updatable<E: Clone + Debug>( &self, ) -> PointerDereferencer<*const RwLock<dyn Updatable<E> + '_>>
where T: Updatable<E>,

Source

pub const fn as_dyn_getter<U, E: Clone + Debug>( &self, ) -> PointerDereferencer<*const RwLock<dyn Getter<U, E> + '_>>
where T: Getter<U, E>,

Source

pub const fn as_dyn_settable<U, E: Clone + Debug>( &self, ) -> PointerDereferencer<*const RwLock<dyn Settable<U, E> + '_>>
where T: Settable<U, E>,

Source

pub const fn as_dyn_time_getter<E: Clone + Debug>( &self, ) -> PointerDereferencer<*const RwLock<dyn TimeGetter<E> + '_>>
where T: TimeGetter<E>,

Source§

impl<T> PointerDereferencer<*const Mutex<T>>

These functions get a PointerDereferencer<*const Mutex<dyn Trait>> from a PointerDereferencer<*const Mutex<T>> where T: Trait. Because raw pointers are Copy, they only require &self and do not consume the original PointerDereferencer. Unfortunately T currently must be Sized due to language limitations.

Source

pub const fn as_dyn_updatable<E: Clone + Debug>( &self, ) -> PointerDereferencer<*const Mutex<dyn Updatable<E> + '_>>
where T: Updatable<E>,

Source

pub const fn as_dyn_getter<U, E: Clone + Debug>( &self, ) -> PointerDereferencer<*const Mutex<dyn Getter<U, E> + '_>>
where T: Getter<U, E>,

Source

pub const fn as_dyn_settable<U, E: Clone + Debug>( &self, ) -> PointerDereferencer<*const Mutex<dyn Settable<U, E> + '_>>
where T: Settable<U, E>,

Source

pub const fn as_dyn_time_getter<E: Clone + Debug>( &self, ) -> PointerDereferencer<*const Mutex<dyn TimeGetter<E> + '_>>
where T: TimeGetter<E>,

Source§

impl<T> PointerDereferencer<*const T>

Source

pub const fn as_dyn_chronology<U>( &self, ) -> PointerDereferencer<*const dyn Chronology<U> + '_>
where T: Chronology<U>,

Trait Implementations§

Source§

impl<T, C: ?Sized + Chronology<T>> Chronology<T> for PointerDereferencer<*mut C>

Source§

fn get(&self, time: Time) -> Option<Datum<T>>

Get a value at a time.
Source§

impl<T, C: ?Sized + Chronology<T>> Chronology<T> for PointerDereferencer<*const C>

Source§

fn get(&self, time: Time) -> Option<Datum<T>>

Get a value at a time.
Source§

impl<P: Clone> Clone for PointerDereferencer<P>

Source§

fn clone(&self) -> PointerDereferencer<P>

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<P: Copy> Copy for PointerDereferencer<P>

Source§

impl<P: Debug> Debug for PointerDereferencer<P>

Source§

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

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

impl<P: Eq> Eq for PointerDereferencer<P>

Source§

impl<T, G: ?Sized + Getter<T, E>, E: Clone + Debug> Getter<T, E> for PointerDereferencer<*mut G>

Source§

fn get(&self) -> Output<T, E>

Get something, fallibly, with a timestamp.
Source§

fn update_and_get(&mut self) -> Output<G, E>

Update with Updatable and then call get.
Source§

impl<G: ?Sized + Getter<T, E>, T, E: Clone + Debug> Getter<T, E> for PointerDereferencer<*const RwLock<G>>

Available on crate feature std only.
Source§

fn get(&self) -> Output<T, E>

Get something, fallibly, with a timestamp.
Source§

fn update_and_get(&mut self) -> Output<G, E>

Update with Updatable and then call get.
Source§

impl<G: ?Sized + Getter<T, E>, T, E: Clone + Debug> Getter<T, E> for PointerDereferencer<*const Mutex<G>>

Available on crate feature std only.
Source§

fn get(&self) -> Output<T, E>

Get something, fallibly, with a timestamp.
Source§

fn update_and_get(&mut self) -> Output<G, E>

Update with Updatable and then call get.
Source§

impl<P: PartialEq> PartialEq for PointerDereferencer<P>

Source§

fn eq(&self, other: &PointerDereferencer<P>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T, S: ?Sized + Settable<T, E>, E: Clone + Debug> Settable<T, E> for PointerDereferencer<*mut S>

Source§

fn set(&mut self, value: T) -> NothingOrError<E>

Set something to a value. For example, this could set a motor to a voltage.
Source§

impl<S: ?Sized + Settable<T, E>, T, E: Clone + Debug> Settable<T, E> for PointerDereferencer<*const RwLock<S>>

Available on crate feature std only.
Source§

fn set(&mut self, value: T) -> NothingOrError<E>

Set something to a value. For example, this could set a motor to a voltage.
Source§

impl<S: ?Sized + Settable<T, E>, T, E: Clone + Debug> Settable<T, E> for PointerDereferencer<*const Mutex<S>>

Available on crate feature std only.
Source§

fn set(&mut self, value: T) -> NothingOrError<E>

Set something to a value. For example, this could set a motor to a voltage.
Source§

impl<P: PartialEq> StructuralPartialEq for PointerDereferencer<P>

Source§

impl<TG: ?Sized + TimeGetter<E>, E: Clone + Debug> TimeGetter<E> for PointerDereferencer<*mut TG>

Source§

fn get(&self) -> TimeOutput<E>

Get the time.
Source§

impl<TG: ?Sized + TimeGetter<E>, E: Clone + Debug> TimeGetter<E> for PointerDereferencer<*const RwLock<TG>>

Available on crate feature std only.
Source§

fn get(&self) -> TimeOutput<E>

Get the time.
Source§

impl<TG: ?Sized + TimeGetter<E>, E: Clone + Debug> TimeGetter<E> for PointerDereferencer<*const Mutex<TG>>

Available on crate feature std only.
Source§

fn get(&self) -> TimeOutput<E>

Get the time.
Source§

impl<U: ?Sized + Updatable<E>, E: Clone + Debug> Updatable<E> for PointerDereferencer<*mut U>

Source§

fn update(&mut self) -> NothingOrError<E>

As this trait is very generic, exactly what this does will be very dependent on the implementor.
Source§

impl<U: ?Sized + Updatable<E>, E: Clone + Debug> Updatable<E> for PointerDereferencer<*const RwLock<U>>

Available on crate feature std only.
Source§

fn update(&mut self) -> NothingOrError<E>

As this trait is very generic, exactly what this does will be very dependent on the implementor.
Source§

impl<U: ?Sized + Updatable<E>, E: Clone + Debug> Updatable<E> for PointerDereferencer<*const Mutex<U>>

Available on crate feature std only.
Source§

fn update(&mut self) -> NothingOrError<E>

As this trait is very generic, exactly what this does will be very dependent on the implementor.

Auto Trait Implementations§

§

impl<P> Freeze for PointerDereferencer<P>
where P: Freeze,

§

impl<P> RefUnwindSafe for PointerDereferencer<P>
where P: RefUnwindSafe,

§

impl<P> Send for PointerDereferencer<P>
where P: Send,

§

impl<P> Sync for PointerDereferencer<P>
where P: Sync,

§

impl<P> Unpin for PointerDereferencer<P>
where P: Unpin,

§

impl<P> UnsafeUnpin for PointerDereferencer<P>
where P: UnsafeUnpin,

§

impl<P> UnwindSafe for PointerDereferencer<P>
where P: UnwindSafe,

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.