pub struct RwLock<T, Codec = Default> { /* private fields */ }Expand description
A lock that allows reading and writing of a shared value, possibly stored on a remote endpoint.
This can be cloned and sent to remote endpoints
Implementations§
Source§impl<T, Codec> RwLock<T, Codec>
impl<T, Codec> RwLock<T, Codec>
Sourcepub fn owner(&self) -> Option<&Arc<TokioRwLock<T>>>
pub fn owner(&self) -> Option<&Arc<TokioRwLock<T>>>
Returns owner if it exist
Sourcepub async fn owner_read(&self) -> Option<TokioRwLockReadGuard<'_, T>>
pub async fn owner_read(&self) -> Option<TokioRwLockReadGuard<'_, T>>
Locks the owner shared value for reading and returns a reference to it, without synchronizing with remote endpoints
Sourcepub async fn owner_write(&self) -> Option<TokioRwLockWriteGuard<'_, T>>
pub async fn owner_write(&self) -> Option<TokioRwLockWriteGuard<'_, T>>
Locks the owner shared value for reading and writing and returns a mutable reference to it, without synchronizing with remote endpoints
Source§impl<T: RemoteSend + Clone + Sync, Codec: Codec> RwLock<T, Codec>
impl<T: RemoteSend + Clone + Sync, Codec: Codec> RwLock<T, Codec>
Sourcepub fn new(value: T) -> Self
pub fn new(value: T) -> Self
Creates a new RwLock<T> with an owner with the specified shared value.
Sourcepub async fn read(&self) -> Result<RwLockReadGuard<'_, T, Codec>, LockError>
pub async fn read(&self) -> Result<RwLockReadGuard<'_, T, Codec>, LockError>
Locks the current shared value for reading and returns a reference to it.
Sourcepub async fn write(&self) -> Result<RwLockWriteGuard<'_, T, Codec>, LockError>
pub async fn write(&self) -> Result<RwLockWriteGuard<'_, T, Codec>, LockError>
Locks the current shared value for reading and writing and returns a mutable reference to it.
To commit the new value RwLockWriteGuard::commit must be called, otherwise the changes will be lost.
Trait Implementations§
Source§impl<'de, T: RemoteSend + Clone + Sync, Codec: Codec> Deserialize<'de> for RwLock<T, Codec>
impl<'de, T: RemoteSend + Clone + Sync, Codec: Codec> Deserialize<'de> for RwLock<T, Codec>
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>,
Auto Trait Implementations§
impl<T, Codec> Freeze for RwLock<T, Codec>
impl<T, Codec = Json> !RefUnwindSafe for RwLock<T, Codec>
impl<T, Codec> Send for RwLock<T, Codec>
impl<T, Codec> Sync for RwLock<T, Codec>
impl<T, Codec> Unpin for RwLock<T, Codec>
impl<T, Codec = Json> !UnwindSafe for RwLock<T, Codec>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)