#[repr(transparent)]pub struct ArcAnchor<T: ?Sized>(pub Arc<T>);Expand description
Serialization public API is defined at crate root
A wrapper around Arc<T> that opt-ins a field for 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>Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for ArcAnchor<T>
impl<'de, T> Deserialize<'de> for ArcAnchor<T>
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<T: ?Sized> Eq for ArcAnchor<T>
Auto Trait Implementations§
impl<T> Freeze for ArcAnchor<T>where
T: ?Sized,
impl<T> RefUnwindSafe for ArcAnchor<T>where
T: RefUnwindSafe + ?Sized,
impl<T> Send for ArcAnchor<T>
impl<T> Sync for ArcAnchor<T>
impl<T> Unpin for ArcAnchor<T>where
T: ?Sized,
impl<T> UnwindSafe for ArcAnchor<T>where
T: RefUnwindSafe + ?Sized,
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