#[repr(transparent)]pub struct ArcWeakAnchor<T: ?Sized>(pub Weak<T>);Expand description
Serialization public API is defined at crate root
A wrapper around [Weak<T>] (from std::sync) that opt-ins for 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 + ?Sized> Clone for ArcWeakAnchor<T>
impl<T: Clone + ?Sized> 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 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: ?Sized> Debug for ArcWeakAnchor<T>
impl<T: ?Sized> Debug for ArcWeakAnchor<T>
Source§impl<'de, T> Deserialize<'de> for ArcWeakAnchor<T>
impl<'de, T> Deserialize<'de> for ArcWeakAnchor<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
Source§impl<T: ?Sized> PartialEq for ArcWeakAnchor<T>
impl<T: ?Sized> PartialEq for ArcWeakAnchor<T>
Source§impl<T: Serialize> Serialize for ArcWeakAnchor<T>
impl<T: Serialize> Serialize for ArcWeakAnchor<T>
impl<T: ?Sized> Eq for ArcWeakAnchor<T>
Auto Trait Implementations§
impl<T> Freeze for ArcWeakAnchor<T>where
T: ?Sized,
impl<T> RefUnwindSafe for ArcWeakAnchor<T>where
T: RefUnwindSafe + ?Sized,
impl<T> Send for ArcWeakAnchor<T>
impl<T> Sync for ArcWeakAnchor<T>
impl<T> Unpin for ArcWeakAnchor<T>where
T: ?Sized,
impl<T> UnwindSafe for ArcWeakAnchor<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