pub struct CurrentCellRef { /* private fields */ }Expand description
A reference to a task’s cell with methods that allow updating the contents of the cell.
Mutations should not outside of the task that that owns this cell. Doing so is a logic error, and may lead to incorrect caching behavior.
Implementations§
Source§impl CurrentCellRef
impl CurrentCellRef
Sourcepub fn conditional_update<T>(
&self,
functor: impl FnOnce(Option<&T>) -> Option<T>,
)where
T: VcValueType,
pub fn conditional_update<T>(
&self,
functor: impl FnOnce(Option<&T>) -> Option<T>,
)where
T: VcValueType,
Updates the cell if the given functor returns a value.
Updates the cell if the given functor returns a SharedReference.
Sourcepub fn compare_and_update<T>(&self, new_value: T)where
T: PartialEq + VcValueType,
pub fn compare_and_update<T>(&self, new_value: T)where
T: PartialEq + VcValueType,
Replace the current cell’s content with new_value if the current content is not equal by
value with the existing content.
The comparison happens using the value itself, not the VcRead::Target of that value.
Take this example of a custom equality implementation on a transparent wrapper type:
#[turbo_tasks::value(transparent, eq = "manual")]
struct Wrapper(Vec<u32>);
impl PartialEq for Wrapper {
fn eq(&self, other: Wrapper) {
// Example: order doesn't matter for equality
let (mut this, mut other) = (self.clone(), other.clone());
this.sort_unstable();
other.sort_unstable();
this == other
}
}
impl Eq for Wrapper {}Comparisons of Vc<Wrapper> used when updating the cell will use Wrapper’s custom
equality implementation, rather than the one provided by the target (Vec<u32>) type.
However, in most cases, the default derived implementation of PartialEq is used which
just forwards to the inner value’s PartialEq.
If you already have a SharedReference, consider calling
Self::compare_and_update_with_shared_reference which can re-use the SharedReference
object.
Replace the current cell’s content with new_shared_reference if the
current content is not equal by value with the existing content.
If you already have a SharedReference, this is a faster version of
CurrentCellRef::compare_and_update.
The SharedReference is expected to use the <T::Read as VcRead<T>>::Repr type for its representation of the value.
Sourcepub fn update<T>(&self, new_value: T, verification_mode: VerificationMode)where
T: VcValueType,
pub fn update<T>(&self, new_value: T, verification_mode: VerificationMode)where
T: VcValueType,
Unconditionally updates the content of the cell.
A faster version of Self::update if you already have a
SharedReference.
If the passed-in SharedReference is the same as the existing cell’s
by identity, no update is performed.
The SharedReference is expected to use the <T::Read as VcRead<T>>::Repr type for its representation of the value.
Trait Implementations§
Source§impl Clone for CurrentCellRef
impl Clone for CurrentCellRef
Source§fn clone(&self) -> CurrentCellRef
fn clone(&self) -> CurrentCellRef
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'de> Deserialize<'de> for CurrentCellRef
impl<'de> Deserialize<'de> for CurrentCellRef
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>,
Source§impl From<CurrentCellRef> for RawVc
impl From<CurrentCellRef> for RawVc
Source§fn from(cell: CurrentCellRef) -> Self
fn from(cell: CurrentCellRef) -> Self
Source§impl Serialize for CurrentCellRef
impl Serialize for CurrentCellRef
impl Copy for CurrentCellRef
Auto Trait Implementations§
impl Freeze for CurrentCellRef
impl RefUnwindSafe for CurrentCellRef
impl Send for CurrentCellRef
impl Sync for CurrentCellRef
impl Unpin for CurrentCellRef
impl UnwindSafe for CurrentCellRef
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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,
§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