Struct BSTSmartPointer

Source
#[repr(C)]
pub struct BSTSmartPointer<T, M = BSTSmartPointerIntrusiveRefCount>{ /* private fields */ }
Expand description

Smart pointer with customizable reference management.

This smart pointer optionally manages reference counts depending on the M parameter.

§Panics

Dereferencing a null pointer via Deref or DerefMut will panic. Use [as_ref] or [is_null] to avoid this panic.

Implementations§

Source§

impl<T, M> BSTSmartPointer<T, M>

Source

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

Creates a new smart pointer from a raw pointer.

§Safety

The pointer must be created from TESBox(MemoryManager::allocate).

Source

pub fn from_non_null(ptr: NonNull<T>) -> Self

Creates a new smart pointer from a raw pointer.

Source

pub fn reset(&mut self)

Replaces the internal pointer with null and releases the old object.

After calling this, [is_null] returns true.

Source

pub fn from_box(value: TESBox<T>) -> Self

Creates a smart pointer from a TESBox, taking ownership.

Source

pub const fn as_ref(&self) -> Option<&T>

Returns an immutable reference to the managed object, or None if the pointer is null.

Use this to safely access the internal object without risking a panic.

Source

pub const fn as_mut(&mut self) -> Option<&mut T>

Returns a mutable reference to the managed object, or None if the pointer is null.

Source

pub const fn as_ptr(&self) -> *mut T

Returns the raw pointer to the managed object.

Source

pub const fn is_null(&self) -> bool

Returns true if the internal pointer is null.

Trait Implementations§

Source§

impl<T, M> Clone for BSTSmartPointer<T, M>

Source§

fn clone(&self) -> Self

Returns a copy 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, M> Debug for BSTSmartPointer<T, M>

Source§

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

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

impl<T, M> Default for BSTSmartPointer<T, M>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T, M> Deref for BSTSmartPointer<T, M>

Source§

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

Dereferences the smart pointer to the managed object.

§Panics

Panics if the internal pointer is null.

Source§

type Target = T

The resulting type after dereferencing.
Source§

impl<T, M> DerefMut for BSTSmartPointer<T, M>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Dereferences the smart pointer mutably.

§Panics

Panics if the internal pointer is null.

Source§

impl<T, M> Drop for BSTSmartPointer<T, M>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T, M> PartialEq<*mut T> for BSTSmartPointer<T, M>

Source§

fn eq(&self, other: &*mut T) -> 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, M> PartialEq<NonNull<T>> for BSTSmartPointer<T, M>

Source§

fn eq(&self, other: &NonNull<T>) -> 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, M> PartialEq<Option<*mut T>> for BSTSmartPointer<T, M>

Source§

fn eq(&self, other: &Option<*mut T>) -> 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, M> PartialEq for BSTSmartPointer<T, M>

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, M> Eq for BSTSmartPointer<T, M>

Auto Trait Implementations§

§

impl<T, M> Freeze for BSTSmartPointer<T, M>

§

impl<T, M> RefUnwindSafe for BSTSmartPointer<T, M>

§

impl<T, M> Send for BSTSmartPointer<T, M>
where M: Send, T: Send,

§

impl<T, M> Sync for BSTSmartPointer<T, M>
where M: Sync, T: Sync,

§

impl<T, M> Unpin for BSTSmartPointer<T, M>
where M: Unpin, T: Unpin,

§

impl<T, M> UnwindSafe for BSTSmartPointer<T, M>

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Formattable for T
where T: Deref, <T as Deref>::Target: Formattable,

Source§

impl<T> Parsable for T
where T: Deref, <T as Deref>::Target: Parsable,