pub struct SyncContiguousEntryRef<T: ?Sized> { /* private fields */ }
Expand description
A synchronized (thread-safe) reference to T
data stored in a
ContiguousMemoryStorage
structure.
Implementations§
Source§impl<T: ?Sized> SyncContiguousEntryRef<T>
impl<T: ?Sized> SyncContiguousEntryRef<T>
Sourcepub fn range(&self) -> ByteRange
pub fn range(&self) -> ByteRange
Returns a byte range within container memory this reference points to.
Sourcepub fn get(
&self,
) -> Result<MemoryReadGuard<'_, T, ImplConcurrent>, LockingError>where
T: RefSizeReq,
pub fn get(
&self,
) -> Result<MemoryReadGuard<'_, T, ImplConcurrent>, LockingError>where
T: RefSizeReq,
Returns a reference to data at its current location or returns a
LockingError::Poisoned
error
if the Mutex holding the base
address pointer has been poisoned.
If the data is mutably accessed, this method will block the current thread until it becomes available.
Sourcepub fn try_get(
&self,
) -> Result<MemoryReadGuard<'_, T, ImplConcurrent>, LockingError>where
T: RefSizeReq,
pub fn try_get(
&self,
) -> Result<MemoryReadGuard<'_, T, ImplConcurrent>, LockingError>where
T: RefSizeReq,
Returns a reference to data at its current location or returns a
LockingError::Poisoned
error
if the Mutex holding the base
address pointer has been poisoned.
If the data is mutably accessed, this method returns a
LockingError::WouldBlock
error.
Sourcepub fn get_mut(
&mut self,
) -> Result<MemoryWriteGuard<'_, T, ImplConcurrent>, LockingError>where
T: RefSizeReq,
pub fn get_mut(
&mut self,
) -> Result<MemoryWriteGuard<'_, T, ImplConcurrent>, LockingError>where
T: RefSizeReq,
Returns or write guard to referenced data at its current location a
LockingError::Poisoned
error if the Mutex holding the base address
pointer or the Mutex holding concurrent mutable access flag has been
poisoned.
Sourcepub fn try_get_mut(
&mut self,
) -> Result<MemoryWriteGuard<'_, T, ImplConcurrent>, LockingError>where
T: RefSizeReq,
pub fn try_get_mut(
&mut self,
) -> Result<MemoryWriteGuard<'_, T, ImplConcurrent>, LockingError>where
T: RefSizeReq,
Returns a write guard to referenced data at its current location or a
LockingError
if that isn’t possible.
§Errors
This function can return the following errors:
-
LockingError::Poisoned
error if the Mutex holding the base address pointer or the Mutex holding mutable access exclusion flag has been poisoned. -
LockingError::WouldBlock
error if accessing referenced data chunk would be blocking.
Sourcepub fn into_dyn<R: ?Sized>(self) -> SyncContiguousEntryRef<R>
Available on crate feature ptr_metadata
only.
pub fn into_dyn<R: ?Sized>(self) -> SyncContiguousEntryRef<R>
ptr_metadata
only.Casts this reference into a dynamic type R
.
Sourcepub fn downcast_dyn<R: Unsize<T>>(self) -> Option<SyncContiguousEntryRef<R>>
Available on crate feature ptr_metadata
only.
pub fn downcast_dyn<R: Unsize<T>>(self) -> Option<SyncContiguousEntryRef<R>>
ptr_metadata
only.Tries downcasting this dynamic reference into a discrete type R
,
returns None if R
drop handler doesn’t match the original one.
Sourcepub unsafe fn with_metadata<R: ?Sized>(
self,
metadata: <R as Pointee>::Metadata,
) -> ContiguousEntryRef<R>
Available on crate feature ptr_metadata
only.
pub unsafe fn with_metadata<R: ?Sized>( self, metadata: <R as Pointee>::Metadata, ) -> ContiguousEntryRef<R>
ptr_metadata
only.Transmutes this reference to type R
with provided metadata
.
static_metadata
function may be used to
statically construct metadata for a struct-trait pair.
§Safety
Sourcepub unsafe fn as_ptr(&self) -> Result<*const T, LockingError>where
T: RefSizeReq,
pub unsafe fn as_ptr(&self) -> Result<*const T, LockingError>where
T: RefSizeReq,
Creates an immutable pointer to underlying data, blocking the current thread until base address can be read.
This function can return a LockingError::Poisoned
error if the Mutex
holding the base address pointer has been poisoned.
§Safety
Sourcepub unsafe fn as_ptr_mut(&self) -> Result<*mut T, LockingError>where
T: RefSizeReq,
pub unsafe fn as_ptr_mut(&self) -> Result<*mut T, LockingError>where
T: RefSizeReq,
Creates a mutable pointer to underlying data, blocking the current thread until base address can be read.
This function can return a LockingError::Poisoned
error if the Mutex
holding the base address pointer has been poisoned.
§Safety
Sourcepub unsafe fn into_ptr(self) -> Result<*const T, LockingError>where
T: RefSizeReq,
pub unsafe fn into_ptr(self) -> Result<*const T, LockingError>where
T: RefSizeReq,
Creates an immutable pointer to underlying data while also preventing the occupied memory region from being marked as free, blocking the current thread until base address can be read
This function can return a LockingError::Poisoned
error if the Mutex
holding the base address pointer has been poisoned.
§Safety
Sourcepub unsafe fn into_ptr_mut(self) -> Result<*mut T, LockingError>where
T: RefSizeReq,
pub unsafe fn into_ptr_mut(self) -> Result<*mut T, LockingError>where
T: RefSizeReq,
Creates a mutable pointer to underlying data while also preventing the occupied memory region from being marked as free, blocking the current thread until base address can be read
This function can return a LockingError::Poisoned
error if the Mutex
holding the base address pointer has been poisoned.