#[repr(C)]pub struct BSTSmartPointer<T, M = BSTSmartPointerIntrusiveRefCount>where
T: BSIntrusiveRefCountedTrait,
M: ManageBSTSmartPointer,{ /* 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>where
T: BSIntrusiveRefCountedTrait,
M: ManageBSTSmartPointer,
impl<T, M> BSTSmartPointer<T, M>where
T: BSIntrusiveRefCountedTrait,
M: ManageBSTSmartPointer,
Sourcepub unsafe fn new(ptr: *mut T) -> Self
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
).
Sourcepub fn from_non_null(ptr: NonNull<T>) -> Self
pub fn from_non_null(ptr: NonNull<T>) -> Self
Creates a new smart pointer from a raw pointer.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Replaces the internal pointer with null and releases the old object.
After calling this, [is_null
] returns true
.
Sourcepub fn from_box(value: TESBox<T>) -> Self
pub fn from_box(value: TESBox<T>) -> Self
Creates a smart pointer from a TESBox
, taking ownership.
Sourcepub const fn as_ref(&self) -> Option<&T>
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.
Trait Implementations§
Source§impl<T, M> Clone for BSTSmartPointer<T, M>where
T: BSIntrusiveRefCountedTrait,
M: ManageBSTSmartPointer,
impl<T, M> Clone for BSTSmartPointer<T, M>where
T: BSIntrusiveRefCountedTrait,
M: ManageBSTSmartPointer,
Source§impl<T, M> Debug for BSTSmartPointer<T, M>
impl<T, M> Debug for BSTSmartPointer<T, M>
Source§impl<T, M> Default for BSTSmartPointer<T, M>where
T: BSIntrusiveRefCountedTrait,
M: ManageBSTSmartPointer,
impl<T, M> Default for BSTSmartPointer<T, M>where
T: BSIntrusiveRefCountedTrait,
M: ManageBSTSmartPointer,
Source§impl<T, M> Deref for BSTSmartPointer<T, M>where
T: BSIntrusiveRefCountedTrait,
M: ManageBSTSmartPointer,
impl<T, M> Deref for BSTSmartPointer<T, M>where
T: BSIntrusiveRefCountedTrait,
M: ManageBSTSmartPointer,
Source§impl<T, M> DerefMut for BSTSmartPointer<T, M>where
T: BSIntrusiveRefCountedTrait,
M: ManageBSTSmartPointer,
impl<T, M> DerefMut for BSTSmartPointer<T, M>where
T: BSIntrusiveRefCountedTrait,
M: ManageBSTSmartPointer,
Source§impl<T, M> Drop for BSTSmartPointer<T, M>where
T: BSIntrusiveRefCountedTrait,
M: ManageBSTSmartPointer,
impl<T, M> Drop for BSTSmartPointer<T, M>where
T: BSIntrusiveRefCountedTrait,
M: ManageBSTSmartPointer,
Source§impl<T, M> PartialEq<*mut T> for BSTSmartPointer<T, M>where
T: BSIntrusiveRefCountedTrait,
M: ManageBSTSmartPointer,
impl<T, M> PartialEq<*mut T> for BSTSmartPointer<T, M>where
T: BSIntrusiveRefCountedTrait,
M: ManageBSTSmartPointer,
Source§impl<T, M> PartialEq<NonNull<T>> for BSTSmartPointer<T, M>where
T: BSIntrusiveRefCountedTrait,
M: ManageBSTSmartPointer,
impl<T, M> PartialEq<NonNull<T>> for BSTSmartPointer<T, M>where
T: BSIntrusiveRefCountedTrait,
M: ManageBSTSmartPointer,
Source§impl<T, M> PartialEq<Option<*mut T>> for BSTSmartPointer<T, M>where
T: BSIntrusiveRefCountedTrait,
M: ManageBSTSmartPointer,
impl<T, M> PartialEq<Option<*mut T>> for BSTSmartPointer<T, M>where
T: BSIntrusiveRefCountedTrait,
M: ManageBSTSmartPointer,
Source§impl<T, M> PartialEq for BSTSmartPointer<T, M>where
T: BSIntrusiveRefCountedTrait,
M: ManageBSTSmartPointer,
impl<T, M> PartialEq for BSTSmartPointer<T, M>where
T: BSIntrusiveRefCountedTrait,
M: ManageBSTSmartPointer,
impl<T, M> Eq for BSTSmartPointer<T, M>where
T: BSIntrusiveRefCountedTrait,
M: ManageBSTSmartPointer,
Auto Trait Implementations§
impl<T, M> Freeze for BSTSmartPointer<T, M>
impl<T, M> RefUnwindSafe for BSTSmartPointer<T, M>where
M: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, M> Send for BSTSmartPointer<T, M>
impl<T, M> Sync for BSTSmartPointer<T, M>
impl<T, M> Unpin for BSTSmartPointer<T, M>
impl<T, M> UnwindSafe for BSTSmartPointer<T, M>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more