pub struct SafePtr<T> { /* private fields */ }Expand description
Safe pointer wrapper that prevents raw pointer dereference
Implementations§
Source§impl<T> SafePtr<T>
impl<T> SafePtr<T>
Sourcepub unsafe fn new(ptr: NonNull<T>) -> SafePtr<T>
pub unsafe fn new(ptr: NonNull<T>) -> SafePtr<T>
Create a new safe pointer from a raw pointer
§Safety
The caller must ensure:
- The pointer is valid and properly aligned
- The memory is initialized for the lifetime of this pointer
- No other mutable references exist to this memory
Sourcepub unsafe fn as_ptr(&self) -> *const T
pub unsafe fn as_ptr(&self) -> *const T
Get the raw pointer value for FFI operations
§Safety
The returned pointer should only be used with appropriate safety checks
Sourcepub unsafe fn as_mut_ptr(&self) -> *mut T
pub unsafe fn as_mut_ptr(&self) -> *mut T
Get a mutable raw pointer for FFI operations
§Safety
The returned pointer should only be used with appropriate safety checks
Trait Implementations§
impl<T> Send for SafePtr<T>where
T: Send,
impl<T> Sync for SafePtr<T>where
T: Sync,
Auto Trait Implementations§
impl<T> Freeze for SafePtr<T>
impl<T> RefUnwindSafe for SafePtr<T>where
T: RefUnwindSafe,
impl<T> Unpin for SafePtr<T>where
T: Unpin,
impl<T> UnwindSafe for SafePtr<T>where
T: RefUnwindSafe + UnwindSafe,
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more