Struct vtable::VRcMapped

source ·
pub struct VRcMapped<VTable: VTableMetaDropInPlace + 'static, MappedType: ?Sized> { /* private fields */ }
Expand description

VRcMapped allows bundling a VRc of a type along with a reference to an object that’s reachable through the data the VRc owns and that satisfies the requirements of a Pin. VRCMapped is constructed using VRc::map and, like VRc, has a weak counterpart, VWeakMapped.

Implementations§

source§

impl<VTable: VTableMetaDropInPlace + 'static, MappedType: ?Sized> VRcMapped<VTable, MappedType>

source

pub fn downgrade(this: &Self) -> VWeakMapped<VTable, MappedType>

Returns a new VWeakMapped that points to this instance and can be upgraded back to a Self as long as a VRc/VMapped exists.

source

pub fn as_pin_ref(&self) -> Pin<&MappedType>

Create a Pinned reference to the mapped type.

This is safe because the map function returns a pinned reference.

source

pub fn map<ReMappedType: ?Sized>( this: Self, map_fn: impl for<'r> FnOnce(Pin<&'r MappedType>) -> Pin<&'r ReMappedType> ) -> VRcMapped<VTable, ReMappedType>

This function allows safely holding a reference to a field inside the VRcMapped. In order to accomplish that, you need to provide a mapping function map_fn in which you need to provide and return a pinned reference to the object you would like to map. The returned VRcMapped allows obtaining that pinned reference again using VRcMapped::as_pin_ref.

See also VRc::map

source

pub fn origin(this: &Self) -> VRc<VTable>

Returns a strong reference to the object that the mapping originates from.

Trait Implementations§

source§

impl<VTable: VTableMetaDropInPlace + 'static, MappedType: ?Sized> Clone for VRcMapped<VTable, MappedType>

source§

fn clone(&self) -> Self

Returns a copy 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<VTable: VTableMetaDropInPlace + 'static, MappedType: ?Sized> Deref for VRcMapped<VTable, MappedType>

§

type Target = MappedType

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<VTable, MappedType: ?Sized> Freeze for VRcMapped<VTable, MappedType>

§

impl<VTable, MappedType: ?Sized> RefUnwindSafe for VRcMapped<VTable, MappedType>
where MappedType: RefUnwindSafe, <VTable as VTableMeta>::VTable: RefUnwindSafe,

§

impl<VTable, MappedType> !Send for VRcMapped<VTable, MappedType>

§

impl<VTable, MappedType> !Sync for VRcMapped<VTable, MappedType>

§

impl<VTable, MappedType: ?Sized> Unpin for VRcMapped<VTable, MappedType>

§

impl<VTable, MappedType: ?Sized> UnwindSafe for VRcMapped<VTable, MappedType>
where MappedType: RefUnwindSafe, <VTable as VTableMeta>::VTable: RefUnwindSafe,

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

§

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

§

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

§

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.