pub struct KeyedReadRef<T>{ /* private fields */ }Expand description
The result of Vc::keyed_reader: a read of a keyed cell (a
cell = "keyed" map or set) that only allows synchronous keyed access via
KeyedReadRef::get and KeyedReadRef::contains_key.
This is an efficient alternative to many Vc::get /
Vc::contains_key reads of the same cell within a single task: the
cell is read (and the dependency registered) only once, and the accessed keys don’t need an
await or any locking of the backend.
While it is alive, the reading task depends on the whole cell, so it is invalidated by any
change. The hashes of the accessed keys are recorded. When it is dropped within the task
execution that read it, that dependency is replaced (in a single batch operation) with
dependencies on only the accessed keys, so the task is only invalidated when one of the
accessed keys changes, like with Vc::get.
It must be dropped within the task execution that called
keyed_reader (it may be dropped in local tasks of that execution),
and the same applies to the future returned by keyed_reader. When either is still alive at the
end of that task execution (e.g. forgotten, or moved to another thread or task), that is a bug
in the task function: completing the execution panics, which aborts the process.
Note: Like with Vc::contains_key, a
contains_key access is also invalidated when the value of the
key changes, not only when its presence changes.
Implementations§
Source§impl<T> KeyedReadRef<T>
impl<T> KeyedReadRef<T>
Sourcepub fn get<Q>(
&self,
key: &Q,
) -> Option<&<<<T as VcValueType>::Read as VcRead<T>>::Target as KeyedAccess<Q>>::Value>
pub fn get<Q>( &self, key: &Q, ) -> Option<&<<<T as VcValueType>::Read as VcRead<T>>::Target as KeyedAccess<Q>>::Value>
Selects a keyed value. The task will only depend on the accessed keys.
Sourcepub fn contains_key<Q>(&self, key: &Q) -> bool
pub fn contains_key<Q>(&self, key: &Q) -> bool
Checks if the value contains the given key. The task will only depend on the accessed keys.
Note: This is also invalidated when the value of the key changes, not only when the presence of the key changes.
Trait Implementations§
Source§impl<T> Debug for KeyedReadRef<T>
impl<T> Debug for KeyedReadRef<T>
Source§impl<T> Drop for KeyedReadRef<T>
impl<T> Drop for KeyedReadRef<T>
Auto Trait Implementations§
impl<T> !Freeze for KeyedReadRef<T>
impl<T> !RefUnwindSafe for KeyedReadRef<T>
impl<T> Forget for KeyedReadRef<T>
impl<T> Move for KeyedReadRef<T>
impl<T> Send for KeyedReadRef<T>
impl<T> Sync for KeyedReadRef<T>
impl<T> Unpin for KeyedReadRef<T>
impl<T> UnsafeUnpin for KeyedReadRef<T>where
ReadRef<T>: UnsafeUnpin,
impl<T> UnwindSafe for KeyedReadRef<T>where
ReadRef<T>: UnwindSafe,
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more