#[repr(transparent)]pub struct ArcAnchor<T>(pub Arc<T>);Expand description
A wrapper around Arc<T> that opts a field into anchor emission (e.g. serialization by reference).
It behaves exactly like an Arc<T> but explicitly marks shared ownership
as an anchor for reference tracking or cross-object linking.
§Examples
use std::sync::Arc;
use serde_saphyr::ArcAnchor;
// Create from an existing Arc
let arc = Arc::new(String::from("Shared"));
let anchor1 = ArcAnchor::from(arc.clone());
// Or create directly from a value
let anchor2: ArcAnchor<String> = ArcAnchor::from(Arc::new(String::from("Data")));
assert_eq!(*anchor1.0, "Shared");
assert_eq!(*anchor2.0, "Data");Tuple Fields§
§0: Arc<T>Implementations§
Trait Implementations§
impl<T> Eq for ArcAnchor<T>
Source§impl<T> From<&ArcAnchor<T>> for ArcWeakAnchor<T>
impl<T> From<&ArcAnchor<T>> for ArcWeakAnchor<T>
Auto Trait Implementations§
impl<T> Freeze for ArcAnchor<T>
impl<T> RefUnwindSafe for ArcAnchor<T>where
Arc<T>: RefUnwindSafe,
impl<T> Send for ArcAnchor<T>
impl<T> Sync for ArcAnchor<T>
impl<T> Unpin for ArcAnchor<T>
impl<T> UnsafeUnpin for ArcAnchor<T>where
Arc<T>: UnsafeUnpin,
impl<T> UnwindSafe for ArcAnchor<T>where
Arc<T>: UnwindSafe,
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
Mutably borrows from an owned value. Read more