Struct rkyv::with::Lock [−][src]
pub struct Lock;Expand description
A wrapper that locks a lock and serializes the value immutably.
This wrapper can panic under very specific circumstances when:
serialize_withis called and succeeds in locking the value to serialize it.- Another thread locks the value and panics, poisoning the lock
resolve_withis called and gets a poisoned value.
Unfortunately, it’s not possible to work around this issue. If your code absolutely must not panic under any circumstances, it’s recommended that you lock your values and then serialize them while locked.
Regular serializers don’t support the custom error handling needed for this type by default. To
use this wrapper, a custom serializer with an error type satisfying
<S as Fallible>::Error: From<LockError> must be provided.
Example
use std::sync::Mutex;
use rkyv::{Archive, with::Lock};
#[derive(Archive)]
struct Example {
#[with(Lock)]
a: Mutex<i32>,
}Trait Implementations
impl<F, T, D> DeserializeWith<Immutable<F>, Mutex<T>, D> for Lock where
F: Deserialize<T, D>,
D: Fallible + ?Sized,
impl<F, T, D> DeserializeWith<Immutable<F>, Mutex<T>, D> for Lock where
F: Deserialize<T, D>,
D: Fallible + ?Sized,
impl<F, T, D> DeserializeWith<Immutable<F>, RwLock<T>, D> for Lock where
F: Deserialize<T, D>,
D: Fallible + ?Sized,
impl<F, T, D> DeserializeWith<Immutable<F>, RwLock<T>, D> for Lock where
F: Deserialize<T, D>,
D: Fallible + ?Sized,
Auto Trait Implementations
impl RefUnwindSafe for Lock
impl UnwindSafe for Lock
Blanket Implementations
type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Converts some archived metadata to the pointer metadata for itself.
Mutably borrows from an owned value. Read more