#[repr(transparent)]pub struct ArcWeakAnchor<T>(pub Weak<T>);Expand description
A wrapper around std::sync::Weak<T> that opts into anchor emission.
This variant is thread-safe and uses Arc / Weak instead of Rc.
If the weak reference is dangling, it serializes as null.
Deserialization note:
null→ dangling weak. Non-nullis rejected unless a registry is used.
§Examples
use std::sync::Arc;
use serde_saphyr::{ArcAnchor, ArcWeakAnchor};
let arc_anchor = ArcAnchor::from(Arc::new(String::from("Thread-safe")));
// Create a weak anchor from the strong reference
let weak_anchor = ArcWeakAnchor::from(&arc_anchor.0);
assert!(weak_anchor.upgrade().is_some());
drop(arc_anchor);
assert!(weak_anchor.upgrade().is_none());Tuple Fields§
§0: Weak<T>Implementations§
Trait Implementations§
Source§impl<T: Clone> Clone for ArcWeakAnchor<T>
impl<T: Clone> Clone for ArcWeakAnchor<T>
Source§fn clone(&self) -> ArcWeakAnchor<T>
fn clone(&self) -> ArcWeakAnchor<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T> Debug for ArcWeakAnchor<T>
impl<T> Debug for ArcWeakAnchor<T>
impl<T> Eq for ArcWeakAnchor<T>
Source§impl<T> From<&Arc<T>> for ArcWeakAnchor<T>
impl<T> From<&Arc<T>> for ArcWeakAnchor<T>
Source§impl<T> From<&ArcAnchor<T>> for ArcWeakAnchor<T>
impl<T> From<&ArcAnchor<T>> for ArcWeakAnchor<T>
Source§impl<T> PartialEq for ArcWeakAnchor<T>
impl<T> PartialEq for ArcWeakAnchor<T>
Auto Trait Implementations§
impl<T> Freeze for ArcWeakAnchor<T>
impl<T> RefUnwindSafe for ArcWeakAnchor<T>where
Weak<T>: RefUnwindSafe,
impl<T> Send for ArcWeakAnchor<T>
impl<T> Sync for ArcWeakAnchor<T>
impl<T> Unpin for ArcWeakAnchor<T>
impl<T> UnsafeUnpin for ArcWeakAnchor<T>where
Weak<T>: UnsafeUnpin,
impl<T> UnwindSafe for ArcWeakAnchor<T>where
Weak<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