Struct backdrop_arc::OffsetArc
source · #[repr(transparent)]pub struct OffsetArc<T, S>where
S: BackdropStrategy<Box<ArcInner<T>>>,{ /* 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>where
S: BackdropStrategy<Box<ArcInner<T>>>,
impl<T, S> OffsetArc<T, S>where S: BackdropStrategy<Box<ArcInner<T>>>,
sourcepub fn with_arc<F, U>(&self, f: F) -> Uwhere
F: FnOnce(&Arc<T, S>) -> U,
pub fn with_arc<F, U>(&self, f: F) -> Uwhere F: FnOnce(&Arc<T, S>) -> 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§
source§impl<T: PartialEq, S> PartialEq<OffsetArc<T, S>> for OffsetArc<T, S>where
S: BackdropStrategy<Box<ArcInner<T>>>,
impl<T: PartialEq, S> PartialEq<OffsetArc<T, S>> for OffsetArc<T, S>where S: BackdropStrategy<Box<ArcInner<T>>>,
impl<T: Eq, S> Eq for OffsetArc<T, S>where S: BackdropStrategy<Box<ArcInner<T>>> + Eq,
impl<T: Sync + Send, S> Send for OffsetArc<T, S>where S: BackdropStrategy<Box<ArcInner<T>>>,
impl<T, S> StructuralEq for OffsetArc<T, S>where S: BackdropStrategy<Box<ArcInner<T>>>,
impl<T: Sync + Send, S> Sync for OffsetArc<T, S>where S: BackdropStrategy<Box<ArcInner<T>>>,
Auto Trait Implementations§
impl<T, S> RefUnwindSafe for OffsetArc<T, S>where S: RefUnwindSafe, T: RefUnwindSafe,
impl<T, S> Unpin for OffsetArc<T, S>where S: Unpin, T: Unpin,
impl<T, S> UnwindSafe for OffsetArc<T, S>where S: UnwindSafe, T: UnwindSafe + RefUnwindSafe,
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, A> DynAccess<T> for Awhere
A: Access<T>,
<A as Access<T>>::Guard: 'static,
impl<T, A> DynAccess<T> for Awhere A: Access<T>, <A as Access<T>>::Guard: 'static,
source§fn load(&self) -> DynGuard<T>
fn load(&self) -> DynGuard<T>
Access::load
.