pub struct RawBlindPooledMut<T>where
T: ?Sized,{ /* private fields */ }Expand description
A unique handle to an object in a RawBlindPool.
The handle can be used to access the pooled object, as well as to remove
it from the pool when no longer needed.
This is a raw handle that requires manual lifetime management of the pooled objects.
- Accessing the target object is only possible via unsafe code as the handle does not know when the pool has been dropped - the caller must guarantee the pool still exists.
- You must explicitly remove the target object from the pool when it is no longer needed.
If the handle is merely dropped, the object it references remains in the pool until
the pool itself is dropped.
This is a unique handle, guaranteeing that no other handles to the same object exist.
You may create both shared and exclusive references to the object through this handle.
The handle may also be converted to a shared handle via
.into_shared(). The handle becomes invalid when the pool is dropped.
§Thread safety
The handle provides access to the underlying object, so its thread-safety characteristics are determined by the type of the object it points to.
If the underlying object is Sync, the handle is thread-mobile (Send). Otherwise, the
handle is single-threaded (neither Send nor Sync).
Implementations§
Source§impl<T: ?Sized> RawBlindPooledMut<T>
impl<T: ?Sized> RawBlindPooledMut<T>
Sourcepub fn ptr(&self) -> NonNull<T>
pub fn ptr(&self) -> NonNull<T>
Get a pointer to the target object.
All pooled objects are guaranteed to be pinned for their entire lifetime, so this pointer remains valid for as long as the object remains in the pool.
The object pool implementation does not keep any references to the pooled objects, so you have the option of using this pointer to create Rust references directly without fear of any conflicting references created by the pool.
Transforms the unique handle into a shared handle that can be cloned and copied freely.
A shared handle does not support the creation of exclusive references to the target object and requires the caller to guarantee that no further access is attempted through any handle after removing the object from the pool.
Sourcepub unsafe fn as_pin(&self) -> Pin<&T>
pub unsafe fn as_pin(&self) -> Pin<&T>
Borrows the target object as a pinned shared reference.
All pooled objects are guaranteed to be pinned for their entire lifetime.
§Safety
The caller must guarantee that the pool will remain alive for the duration the returned reference is used.
Sourcepub unsafe fn as_pin_mut(&mut self) -> Pin<&mut T>
pub unsafe fn as_pin_mut(&mut self) -> Pin<&mut T>
Borrows the target object as a pinned exclusive reference.
All pooled objects are guaranteed to be pinned for their entire lifetime.
§Safety
The caller must guarantee that the pool will remain alive for the duration the returned reference is used.