Struct ContiguousEntryRef

Source
pub struct ContiguousEntryRef<T: ?Sized> { /* private fields */ }
Expand description

A thread-unsafe reference to T data stored in ContiguousMemoryStorage structure.

Implementations§

Source§

impl<T: ?Sized> ContiguousEntryRef<T>

Source

pub fn range(&self) -> ByteRange

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

Source

pub fn get(&self) -> MemoryReadGuard<'_, T, ImplDefault>
where T: RefSizeReq,

Returns a reference to data at its current location and panics if the represented memory region is mutably borrowed.

Source

pub fn try_get( &self, ) -> Result<MemoryReadGuard<'_, T, ImplDefault>, RegionBorrowedError>
where T: RefSizeReq,

Returns a reference to data at its current location or a RegionBorrowedError error if the represented memory region is mutably borrowed.

Source

pub fn get_mut(&mut self) -> MemoryWriteGuard<'_, T, ImplDefault>
where T: RefSizeReq,

Returns a mutable reference to data at its current location and panics if the reference has already been borrowed.

Source

pub fn try_get_mut( &mut self, ) -> Result<MemoryWriteGuard<'_, T, ImplDefault>, RegionBorrowedError>
where T: RefSizeReq,

Returns a mutable reference to data at its current location or a RegionBorrowedError error if the represented memory region is already borrowed.

Source

pub fn into_dyn<R: ?Sized>(self) -> ContiguousEntryRef<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<ContiguousEntryRef<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

This function is unsafe because it assumes any T to implement R, as the original type of stored data can be erased through into_dyn it’s impossible to check whether the initial struct actually implements R.

Calling methods from an incorrect vtable will cause undefined behavior.

Source

pub unsafe fn as_ptr(&self) -> *const T
where T: RefSizeReq,

Creates an immutable pointer to underlying data.

§Safety

This function returns a pointer that may become invalid if the container’s memory is resized to a capacity which requires the memory segment to be moved.

When the reference goes out of scope, its region will be marked as free which means that a subsequent call to ContiguousMemoryStorage::push or friends can cause undefined behavior when dereferencing the pointer.

Source

pub unsafe fn as_ptr_mut(&self) -> *mut T
where T: RefSizeReq,

Creates a mutable pointer to underlying data.

§Safety

In addition to concerns noted in ContiguousEntryRef::as_ptr, this function also provides mutable access to the underlying data allowing potential data races.

Source

pub unsafe fn into_ptr(self) -> *const T
where T: RefSizeReq,

Creates an immutable pointer to underlying data while also preventing the occupied memory region from being marked as free.

§Safety

This function returns a pointer that may become invalid if the container’s memory is resized to a capacity which requires the memory segment to be moved.

Source

pub unsafe fn into_ptr_mut(self) -> *mut T
where T: RefSizeReq,

Creates a mutable pointer to underlying data while also preventing the occupied memory region from being marked as free.

§Safety

In addition to concerns noted in ContiguousEntryRef::into_ptr, this function also provides mutable access to the underlying data allowing potential data races.

Trait Implementations§

Source§

impl<T: ?Sized> Clone for ContiguousEntryRef<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 ContiguousEntryRef<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 ContiguousEntryRef<T>
where T: ?Sized,

§

impl<T> !RefUnwindSafe for ContiguousEntryRef<T>

§

impl<T> !Send for ContiguousEntryRef<T>

§

impl<T> !Sync for ContiguousEntryRef<T>

§

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

§

impl<T> !UnwindSafe for ContiguousEntryRef<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.