[−][src]Struct vtable::VRc
A reference counted pointer to an object matching the virtual table T
Similar to std::rc::Rc
where the VTable
type parameter is a VTable struct
annotated with #[vtable]
, and the X
type parameter is the actual instance.
When X
is the Dyn
type marker, this means that the X is not known and the only
thing that can be done is to get a VRef<VTable>
through the Self::borrow()
function.
Other differences with the std::rc::Rc
types are:
- It does not allow to access mutable reference. (No
get_mut
ormake_mut
), meaning it is safe to get a Pin reference withborrow_pin
. - It is safe to pass it accross ffi boundaries.
Implementations
impl<VTable: VTableMetaDropInPlace, X: HasStaticVTable<VTable>> VRc<VTable, X>
[src]
pub fn new(data: X) -> Self
[src]
Create a new VRc from an instance of a type that can be associated with a VTable.
Will move the instance on the heap.
(the HasStaticVTable
is implemented by the “MyTrait”VTable_static!
macro generated by
the #vtable macro)
pub fn into_dyn(this: Self) -> VRc<VTable, Dyn> where
Self: 'static,
[src]
Self: 'static,
Convert a VRc of a real instance to a VRc of a Dyn instance
impl<VTable: VTableMetaDropInPlace, X> VRc<VTable, X>
[src]
pub fn as_pin_ref(&self) -> Pin<&X>
[src]
Create a Pinned reference to the inner.
This is safe because we don't allow mutable reference to the inner
pub fn borrow(this: &Self) -> VRef<'_, VTable>
[src]
Gets a VRef pointing to this instance
pub fn borrow_pin<'b>(this: &'b Self) -> Pin<VRef<'b, VTable>>
[src]
Gets a Pin
This is safe because there is no way to access a mutable reference to the pointee.
(There is no get_mut
or make_mut
),
pub fn downgrade(this: &Self) -> VWeak<VTable, X>
[src]
Construct a VWeak
pointing to this instance.
pub fn strong_count(this: &Self) -> usize
[src]
Gets the number of strong (VRc) pointers to this allocation.
pub fn ptr_eq(this: &Self, other: &Self) -> bool
[src]
Returns true if the two VRc's point to the same allocation
Trait Implementations
impl<VTable: VTableMetaDropInPlace + 'static, X> Clone for VRc<VTable, X>
[src]
pub fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<VTable: VTableMetaDropInPlace, X> Deref for VRc<VTable, X>
[src]
impl<VTable: VTableMetaDropInPlace + 'static, X> Drop for VRc<VTable, X>
[src]
Auto Trait Implementations
impl<VTable, X = Dyn> !RefUnwindSafe for VRc<VTable, X>
impl<VTable, X = Dyn> !Send for VRc<VTable, X>
impl<VTable, X = Dyn> !Sync for VRc<VTable, X>
impl<VTable, X> Unpin for VRc<VTable, X>
impl<VTable, X = Dyn> !UnwindSafe for VRc<VTable, X>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,