[][src]Struct triomphe::OffsetArc

#[repr(transparent)]pub struct OffsetArc<T> { /* fields omitted */ }

An Arc, except it holds a pointer to the T instead of to the entire ArcInner. This struct is FFI-compatible.

 Arc<T>    OffsetArc<T>
  |          |
  v          v
 ---------------------
| RefCount | T (data) | [ArcInner<T>]
 ---------------------

This means that this is a direct pointer to its contained data (and can be read from by both C++ and Rust), but we can also convert it to a "regular" Arc by removing the offset.

This is very useful if you have an Arc-containing struct shared between Rust and C++, and wish for C++ to be able to read the data behind the Arc without incurring an FFI call overhead.

Implementations

impl<T> OffsetArc<T>[src]

pub fn with_arc<F, U>(&self, f: F) -> U where
    F: FnOnce(&Arc<T>) -> U, 
[src]

Temporarily converts |self| into a bonafide Arc and exposes it to the provided callback. The refcount is not modified.

pub fn make_mut(&mut self) -> &mut T where
    T: Clone
[src]

If uniquely owned, provide a mutable reference Else create a copy, and mutate that

This is functionally the same thing as Arc::make_mut

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

Clone it as an Arc

pub fn borrow_arc<'a>(&'a self) -> ArcBorrow<'a, T>[src]

Produce a pointer to the data that can be converted back to an Arc

Trait Implementations

impl<T> Clone for OffsetArc<T>[src]

impl<T: Debug> Debug for OffsetArc<T>[src]

impl<T> Deref for OffsetArc<T>[src]

type Target = T

The resulting type after dereferencing.

impl<T> Drop for OffsetArc<T>[src]

impl<T: Eq> Eq for OffsetArc<T>[src]

impl<T: PartialEq> PartialEq<OffsetArc<T>> for OffsetArc<T>[src]

impl<T: Sync + Send> Send for OffsetArc<T>[src]

impl<T> StructuralEq for OffsetArc<T>[src]

impl<T: Sync + Send> Sync for OffsetArc<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for OffsetArc<T> where
    T: RefUnwindSafe
[src]

impl<T> Unpin for OffsetArc<T> where
    T: Unpin
[src]

impl<T> UnwindSafe for OffsetArc<T> where
    T: RefUnwindSafe + UnwindSafe
[src]

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