[][src]Struct crndm::ptr::LogNonNull

pub struct LogNonNull<T: PSafe + ?Sized, A: MemPool> { /* fields omitted */ }

An unsafe pointer with dereferencing and logging capability

This type is !PSafe and its constructor functions are unsafe. This is because of LogNonNull treating like a raw pointer. LogNonNull objects are useful for obtaining performance. LogRefCell::as_non_null_mut() is an alternative to LogRefCell::borrow_mut() which provides unsafe mutable access to the underlying data.

PNonNullMut is an alias name in the pool module for LogNonNullMut.

Safety

  • As in raw pointers, LogNonNull is Copy and is not bounded to a specific lifetime.
  • It does not follow the borrow mechanism and thus multiple mutable access is possible.

Examples

use crndm::default::*;
use crndm::ptr::LogNonNull;
 
type P = BuddyAlloc;
 
fn multiply(mut obj: LogNonNull<i32,P>, m: i32) {
    // Takes a log if required and then provides mut ref to the object
    *obj *= m;
}
 
let root = P::open::<PRefCell<i32>>("foo.pool", O_CF).unwrap();
 
P::transaction(|j| {
    let mut borrow = root.borrow_mut(j);
    *borrow = 5;
 
    multiply( unsafe { root.as_non_null_mut(j) }, 10 );
}).unwrap();
 
assert_eq!(*root.borrow(), 50);

Implementations

impl<T: PSafe, A: MemPool> LogNonNull<T, A>[src]

pub const unsafe fn new_unchecked(
    ptr: *mut T,
    logged: *mut u8,
    j: &Journal<A>
) -> Self
[src]

Creates a new LogNonNull.

Safety

ptr and logged must be non-null.

pub unsafe fn new(ptr: *mut T, logged: *mut u8, j: &Journal<A>) -> Option<Self>[src]

Creates a Some(LogNonNull) if ptr is not null; otherwise None.

Trait Implementations

impl<T: PSafe + ?Sized, A: MemPool> Clone for LogNonNull<T, A>[src]

impl<T: PSafe + ?Sized, A: MemPool> Copy for LogNonNull<T, A>[src]

impl<T: Debug + PSafe + ?Sized, A: MemPool> Debug for LogNonNull<T, A>[src]

impl<T: PSafe + ?Sized, A: MemPool> Deref for LogNonNull<T, A>[src]

type Target = T

The resulting type after dereferencing.

impl<T: PSafe + ?Sized, A: MemPool> DerefMut for LogNonNull<T, A>[src]

impl<T: Display + PSafe + ?Sized, A: MemPool> Display for LogNonNull<T, A>[src]

impl<T: ?Sized, A: MemPool> !Send for LogNonNull<T, A>[src]

impl<T: ?Sized, A: MemPool> !Sync for LogNonNull<T, A>[src]

impl<T: ?Sized, A: MemPool> !TxOutSafe for LogNonNull<T, A>[src]

Auto Trait Implementations

impl<T, A> !LooseTxInUnsafe for LogNonNull<T, A>[src]

impl<T, A> !PSafe for LogNonNull<T, A>[src]

impl<T, A> !RefUnwindSafe for LogNonNull<T, A>[src]

impl<T, A> !TxInSafe for LogNonNull<T, A>[src]

impl<T: ?Sized, A> Unpin for LogNonNull<T, A>[src]

impl<T, A> !UnwindSafe for LogNonNull<T, A>[src]

impl<T, A> !VSafe for LogNonNull<T, A>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, A> ToString<A> for T where
    A: MemPool,
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,