pub struct SyncMutPtr<T>(/* private fields */);Expand description
Wrapped mutable raw pointer that is Send+Sync
Implementations§
Source§impl<T> SyncMutPtr<T>
impl<T> SyncMutPtr<T>
Sourcepub const fn new(ptr: *mut T) -> Self
pub const fn new(ptr: *mut T) -> Self
Makes ptr Send+Sync
§Safety
The ptr parameter must be able to handle being sent and used in other threads concurrently,
or special care must be taken when using the wrapped ptr to not use it
in any way in other threads.
Note: This function is potentially always safe to call, rusts specification does not really make it clear why
Sourcepub const fn from_address(addr: usize) -> Self
pub const fn from_address(addr: usize) -> Self
Returns a SyncMutPtr from an arbitrary address.
This is equivalent to casting usize as *mut T
Sourcepub fn as_address(&self) -> usize
pub fn as_address(&self) -> usize
Returns the address of the pointer.
This is equivalent to casting the pointer using *mut T as usize.
§Note
Starting with rust 1.84.0, the pointer itself
has the functions addr and expose_provenance.
These functions should be used instead.
They are available via the deref trait.
This function is roughly equivalent to the expose_provenance function.
Sourcepub const fn cast<Y>(&self) -> SyncMutPtr<Y>
pub const fn cast<Y>(&self) -> SyncMutPtr<Y>
Casts ptr to another data type while keeping it Send+Sync.
Sourcepub const fn as_sync_const(&self) -> SyncConstPtr<T>
pub const fn as_sync_const(&self) -> SyncConstPtr<T>
Makes ptr immutable.
Sourcepub const fn as_send_const(&self) -> SendConstPtr<T>
pub const fn as_send_const(&self) -> SendConstPtr<T>
Makes ptr immutable and no longer Sync.
Sourcepub const fn as_sync_mut(&self) -> Self
pub const fn as_sync_mut(&self) -> Self
This is equivalent to .clone() and does nothing.
Sourcepub const fn as_send_mut(&self) -> SendMutPtr<T>
pub const fn as_send_mut(&self) -> SendMutPtr<T>
Makes ptr no longer Sync.