pub struct WeakSArc<Storage, T>where
Storage: SharedStorage,{ /* private fields */ }Expand description
Weak counterpart to SArc.
A weak handle must be upgraded before borrowing. This keeps “the shared value was dropped” separate from the existing state/storage borrow errors.
ⓘ
let shared = SArcMutex::<Connection>::new::<Disconnected>(connection);
let weak = shared.downgrade();
match weak.upgrade() {
Some(shared) => {
let disconnected = shared.borrow::<Disconnected>()?;
}
None => {
// All strong handles were dropped.
}
}Implementations§
Source§impl<Storage, T> WeakSArc<Storage, T>where
Storage: SharedStorage,
impl<Storage, T> WeakSArc<Storage, T>where
Storage: SharedStorage,
Sourcepub fn upgrade(&self) -> Option<SArc<Storage, T>>
pub fn upgrade(&self) -> Option<SArc<Storage, T>>
Attempts to recover a strong Arc-backed shared-state handle.
This mirrors std::sync::Weak::upgrade. A successful upgrade only
restores ownership of the shared container; typestate validation still
happens at the later borrow/borrow_mut call.
Trait Implementations§
Auto Trait Implementations§
impl<Storage, T> Freeze for WeakSArc<Storage, T>
impl<Storage, T> RefUnwindSafe for WeakSArc<Storage, T>
impl<Storage, T> Send for WeakSArc<Storage, T>
impl<Storage, T> StateClone for WeakSArc<Storage, T>
impl<Storage, T> StateCopy for WeakSArc<Storage, T>
impl<Storage, T> Sync for WeakSArc<Storage, T>
impl<Storage, T> Unpin for WeakSArc<Storage, T>
impl<Storage, T> UnsafeUnpin for WeakSArc<Storage, T>
impl<Storage, T> UnwindSafe for WeakSArc<Storage, T>
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