pub struct OffsetArc<T, S>{ /* private fields */ }Expand description
An Arc, except it holds a pointer to the T instead of to the
entire ArcInner.
An OffsetArc<T, S> has the same layout and ABI as a non-null
const T* in C, and may be used in FFI function signatures.
Arc<T, S> OffsetArc<T, S>
| |
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<T, S> 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§
Source§impl<T, S> OffsetArc<T, S>
impl<T, S> OffsetArc<T, S>
Sourcepub fn with_arc<F, U>(&self, f: F) -> U
pub fn with_arc<F, U>(&self, f: F) -> U
Temporarily converts |self| into a bonafide Arc and exposes it to the provided callback. The refcount is not modified.
Sourcepub fn make_mut(&mut self) -> &mut Twhere
T: Clone,
pub fn make_mut(&mut self) -> &mut Twhere
T: Clone,
If uniquely owned, provide a mutable reference Else create a copy, and mutate that
This is functionally the same thing as Arc::make_mut
Sourcepub fn borrow_arc(&self) -> ArcBorrow<'_, T>
pub fn borrow_arc(&self) -> ArcBorrow<'_, T>
Produce a pointer to the data that can be converted back
to an Arc
Trait Implementations§
impl<T: Eq, S> Eq for OffsetArc<T, S>
impl<T: Sync + Send, S> Send for OffsetArc<T, S>
impl<T: Sync + Send, S> Sync for OffsetArc<T, S>
Auto Trait Implementations§
impl<T, S> Freeze for OffsetArc<T, S>
impl<T, S> RefUnwindSafe for OffsetArc<T, S>where
T: RefUnwindSafe,
S: RefUnwindSafe,
impl<T, S> Unpin for OffsetArc<T, S>
impl<T, S> UnwindSafe for OffsetArc<T, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, A> DynAccess<T> for A
impl<T, A> DynAccess<T> for A
Source§fn load(&self) -> DynGuard<T>
fn load(&self) -> DynGuard<T>
Access::load.