pub struct RawBlindPooled<T>where
T: ?Sized,{ /* private fields */ }Expand description
A shared handle to an object in a RawBlindPool.
§Implications of raw handles
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 shared handle that only grants shared access to the object. No exclusive references can be created through this handle. All handles become invalid once the object is removed from the pool or the pool is dropped.
§Thread safety
The handle provides access to an object of type T, so its thread-safety characteristics
are determined by the type of the object it references.
If the underlying object T is Send then the handle is Send.
If the underlying object T is Sync then the handle is Sync.
Implementations§
Source§impl<T: ?Sized> RawBlindPooled<T>
impl<T: ?Sized> RawBlindPooled<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.
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_ref(&self) -> &T
pub unsafe fn as_ref(&self) -> &T
Borrows the target object via shared reference.
§Safety
The caller must guarantee that the pool remains alive for the duration the returned reference is used.
The caller must guarantee that the object remains in the pool for the duration the returned reference is used.
Sourcepub fn erase(self) -> RawBlindPooled<()>where
T: Send,
pub fn erase(self) -> RawBlindPooled<()>where
T: Send,
Erase the type information from this handle, converting it to RawBlindPooled<()>.
This is useful for extending the lifetime of an object in the pool without retaining type information. The type-erased handle prevents access to the object but ensures it remains in the pool.