Struct SyncContiguousEntryRef

Source
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>

Source

pub fn range(&self) -> ByteRange

Returns a byte range within container memory this reference points to.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn into_dyn<R: ?Sized>(self) -> SyncContiguousEntryRef<R>
where T: Sized + Unsize<R>,

Available on crate feature ptr_metadata only.

Casts this reference into a dynamic type R.

Source

pub fn downcast_dyn<R: Unsize<T>>(self) -> Option<SyncContiguousEntryRef<R>>

Available on crate feature 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.

Source

pub unsafe fn with_metadata<R: ?Sized>( self, metadata: <R as Pointee>::Metadata, ) -> ContiguousEntryRef<R>

Available on crate feature 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

See: ContiguousEntryRef::with_metadata

Source

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

See: ContiguousEntryRef::as_ptr

Source

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

See: ContiguousEntryRef::as_ptr_mut

Source

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

See: ContiguousEntryRef::into_ptr

Source

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.

§Safety

See: ContiguousEntryRef::into_ptr_mut

Trait Implementations§

Source§

impl<T: ?Sized> Clone for SyncContiguousEntryRef<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: ?Sized> Debug for SyncContiguousEntryRef<T>

Available on crate feature debug only.
Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for SyncContiguousEntryRef<T>
where T: ?Sized,

§

impl<T> !RefUnwindSafe for SyncContiguousEntryRef<T>

§

impl<T> Send for SyncContiguousEntryRef<T>
where T: Sync + Send + ?Sized,

§

impl<T> Sync for SyncContiguousEntryRef<T>
where T: Sync + Send + ?Sized,

§

impl<T> Unpin for SyncContiguousEntryRef<T>
where T: ?Sized,

§

impl<T> !UnwindSafe for SyncContiguousEntryRef<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.