pub struct SharedProjection<Root, Value, Get, GetMut> { /* private fields */ }Expand description
Mutates a partial field while retaining its originally captured reference.
Implementations§
Sourcepub fn read<ResultValue>(
&self,
read: impl FnOnce(&Value) -> ResultValue,
) -> Result<ResultValue, SharedAccessError>
pub fn read<ResultValue>( &self, read: impl FnOnce(&Value) -> ResultValue, ) -> Result<ResultValue, SharedAccessError>
Sourcepub fn reader(&self) -> SharedReadProjection<Root, Value, Get>where
Get: Clone,
pub fn reader(&self) -> SharedReadProjection<Root, Value, Get>where
Get: Clone,
Returns a read-only projection onto the same value.
Sourcepub fn update<ResultValue>(
&self,
update: impl FnOnce(&mut Value) -> ResultValue,
publish: impl FnOnce(),
) -> Result<ResultValue, SharedAccessError>
pub fn update<ResultValue>( &self, update: impl FnOnce(&mut Value) -> ResultValue, publish: impl FnOnce(), ) -> Result<ResultValue, SharedAccessError>
Mutates a present payload and explicitly publishes after unlocking.
This never inserts a missing payload or retargets the captured reference. Publication runs exactly once after a normally returning mutation, even when unchanged. The owned result cannot borrow the payload.
§Errors
Returns Busy, Poisoned, or Absent before invoking either callback.
§Panics
A path/mutation panic poisons the reference and skips publication. A publication panic propagates after commit, without poisoning it.
Sourcepub fn try_update<ResultValue, Failure>(
&self,
update: impl FnOnce(&mut Value) -> Result<ResultValue, Failure>,
publish: impl FnOnce(),
) -> Result<ResultValue, SharedMutationError<Failure>>
pub fn try_update<ResultValue, Failure>( &self, update: impl FnOnce(&mut Value) -> Result<ResultValue, Failure>, publish: impl FnOnce(), ) -> Result<ResultValue, SharedMutationError<Failure>>
Mutates a present payload and explicitly publishes after unlocking.
This never inserts a missing payload. A user Err retains its partial
writes and publishes, just like Shared::try_update.
§Errors
Returns uncommitted Busy/Poisoned/Absent or the committed original cause.
§Panics
A path/mutation panic poisons the reference and skips publication. A publication panic propagates after commit, without poisoning it.