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 host(&self) -> Option<&Arc<TokioRwLock<T>>>
pub fn host(&self) -> Option<&Arc<TokioRwLock<T>>>
Returns host if it exist
Sourcepub async fn host_read(&self) -> Option<TokioRwLockReadGuard<'_, T>>
pub async fn host_read(&self) -> Option<TokioRwLockReadGuard<'_, T>>
Locks the host shared value for reading and returns a reference to it, without synchronizing with remote endpoints
Sourcepub async fn host_write(&self) -> Option<TokioRwLockWriteGuard<'_, T>>
pub async fn host_write(&self) -> Option<TokioRwLockWriteGuard<'_, T>>
Locks the host 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 host 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>,
Deserialize this value from the given Serde deserializer. Read more
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
Mutably borrows from an owned value. Read more