[][src]Struct elysees::ArcBorrow

#[repr(transparent)]pub struct ArcBorrow<'a, T: ?Sized + 'a>(_);

A "borrowed Arc". This is a pointer to a T that is known to have been allocated within an Arc.

This is equivalent in guarantees to &ArcHandle<T>, however it is a bit more flexible. To obtain an &ArcHandle<T> you must have an ArcHandle<T> instance somewhere pinned down until we're done with it. It's also a direct pointer to T, so using this involves less pointer-chasing

However, C++ code may hand us refcounted things as pointers to T directly, so we have to conjure up a temporary Arc on the stack each time. The same happens for when the object is managed by a Arc.

ArcBorrow lets us deal with borrows of known-refcounted objects without needing to worry about where the Arc<T> is.

Implementations

impl<'a, T: ?Sized> ArcBorrow<'a, T>[src]

pub fn clone_arc(&self) -> Arc<T>[src]

Clone this as an Arc<T>. This bumps the refcount.

pub fn as_arc(&self) -> &Arc<T>[src]

Borrow this as an Arc<T>. This does not bump the refcount.

pub unsafe fn from_ref(r: &'a T) -> Self[src]

For constructing from a reference known to be Arc-backed, e.g. if we obtain such a reference over FFI

Safety

The reference passed in must be to a T within a valid ArcInner. Valid examples include the result of ArcBorrow::get, Arc::deref, etc. The reference passed in may not be from a T owned by an ArcBox, as this violates the ArcBox's uniqueness guarantees.

pub fn ptr_eq(this: Self, other: Self) -> bool[src]

Compare two ArcBorrows via pointer equality. Will only return true if they come from the same allocation

pub fn get(&self) -> &'a T[src]

Similar to deref, but uses the lifetime |a| rather than the lifetime of self, which is incompatible with the signature of the Deref trait.

pub fn count(this: ArcBorrow<'a, T>, ordering: Ordering) -> usize[src]

Get the reference count of this Arc with a given memory ordering

Trait Implementations

impl<'a, T: ?Sized> AsRef<&'a T> for ArcBorrow<'a, T>[src]

impl<'a, T: ?Sized> AsRef<*const T> for ArcBorrow<'a, T>[src]

impl<'a, T: ?Sized> AsRef<*mut T> for ArcBorrow<'a, T>[src]

impl<'a, T: ?Sized> AsRef<Arc<T>> for ArcBorrow<'a, T>[src]

impl<'a, T: ?Sized> AsRef<NonNull<T>> for ArcBorrow<'a, T>[src]

impl<'a, T: ?Sized> AsRef<T> for ArcBorrow<'a, T>[src]

impl<'a, T: ?Sized> Borrow<&'a T> for ArcBorrow<'a, T>[src]

impl<'a, T: ?Sized> Borrow<*const T> for ArcBorrow<'a, T>[src]

impl<'a, T: ?Sized> Borrow<*mut T> for ArcBorrow<'a, T>[src]

impl<'a, T: ?Sized> Borrow<Arc<T>> for ArcBorrow<'a, T>[src]

impl<'a, T: ?Sized> Borrow<NonNull<T>> for ArcBorrow<'a, T>[src]

impl<'a, T: ?Sized> Borrow<T> for ArcBorrow<'a, T>[src]

impl<'a, T: ?Sized> Clone for ArcBorrow<'a, T>[src]

impl<'a, T: ?Sized> CloneStableDeref for ArcBorrow<'a, T>[src]

impl<'a, T: ?Sized> Copy for ArcBorrow<'a, T>[src]

impl<'a, T: Debug + ?Sized + 'a> Debug for ArcBorrow<'a, T>[src]

impl<'a, T: ?Sized> Deref for ArcBorrow<'a, T>[src]

type Target = T

The resulting type after dereferencing.

impl<'a, T: Eq + ?Sized + 'a> Eq for ArcBorrow<'a, T>[src]

impl<'a, T: ?Sized + Erasable> ErasablePtr for ArcBorrow<'a, T>[src]

impl<'a, T: Hash + ?Sized + 'a> Hash for ArcBorrow<'a, T>[src]

impl<'a, T: Ord + ?Sized + 'a> Ord for ArcBorrow<'a, T>[src]

impl<'a, T: PartialEq + ?Sized + 'a> PartialEq<ArcBorrow<'a, T>> for ArcBorrow<'a, T>[src]

impl<'a, T: PartialOrd + ?Sized + 'a> PartialOrd<ArcBorrow<'a, T>> for ArcBorrow<'a, T>[src]

impl<'a, T: ?Sized + Serialize> Serialize for ArcBorrow<'a, T>[src]

impl<'a, T: ?Sized> StableDeref for ArcBorrow<'a, T>[src]

impl<'a, T: ?Sized + 'a> StructuralEq for ArcBorrow<'a, T>[src]

impl<'a, T: ?Sized + 'a> StructuralPartialEq for ArcBorrow<'a, T>[src]

impl<'a, T: ?Sized> UnionAlign for ArcBorrow<'a, T> where
    ArcBorrow<'a, T>: ErasablePtr
[src]

Auto Trait Implementations

impl<'a, T: ?Sized> RefUnwindSafe for ArcBorrow<'a, T> where
    T: RefUnwindSafe

impl<'a, T: ?Sized> Send for ArcBorrow<'a, T> where
    T: Sync

impl<'a, T: ?Sized> Sync for ArcBorrow<'a, T> where
    T: Sync

impl<'a, T: ?Sized> Unpin for ArcBorrow<'a, T>

impl<'a, T: ?Sized> UnwindSafe for ArcBorrow<'a, T> where
    T: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Erasable for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.