pub struct TransientState<T> { /* private fields */ }Implementations§
Source§impl<T> TransientState<T>
impl<T> TransientState<T>
pub fn new() -> Self
Sourcepub fn get(&self) -> StateRef<'_, Option<T>>
pub fn get(&self) -> StateRef<'_, Option<T>>
Gets the current value of the state. The current task will be registered as dependency of the state and will be invalidated when the state changes.
Sourcepub fn get_untracked(&self) -> StateRef<'_, Option<T>>
pub fn get_untracked(&self) -> StateRef<'_, Option<T>>
Gets the current value of the state. Untracked.
Sourcepub fn set_unconditionally(&self, value: T)
pub fn set_unconditionally(&self, value: T)
Sets the current state without comparing it with the old value. This should only be used if one is sure that the value has changed.
Sourcepub fn unset_unconditionally(&self)
pub fn unset_unconditionally(&self)
Unset the current value without comparing it with the old value. This should only be used if one is sure that the value has changed.
Sourcepub fn update_conditionally(&self, update: impl FnOnce(&mut Option<T>) -> bool)
pub fn update_conditionally(&self, update: impl FnOnce(&mut Option<T>) -> bool)
Updates the current state with the update function. The update
function need to return true when the value was modified. Exposing
the current value from the update function is not allowed and will
result in incorrect cache invalidation.
Trait Implementations§
Source§impl<T: Debug> Debug for TransientState<T>
impl<T: Debug> Debug for TransientState<T>
Source§impl<T> Default for TransientState<T>
impl<T> Default for TransientState<T>
Source§impl<'de, T> Deserialize<'de> for TransientState<T>
impl<'de, T> Deserialize<'de> for TransientState<T>
Source§fn deserialize<D>(deserializer: D) -> Result<TransientState<T>, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<TransientState<T>, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T> PartialEq for TransientState<T>
impl<T> PartialEq for TransientState<T>
Source§impl<T> Serialize for TransientState<T>
impl<T> Serialize for TransientState<T>
Source§impl<T: TraceRawVcs> TraceRawVcs for TransientState<T>
impl<T: TraceRawVcs> TraceRawVcs for TransientState<T>
fn trace_raw_vcs(&self, trace_context: &mut TraceRawVcsContext)
fn get_raw_vcs(&self) -> Vec<RawVc>
impl<T> Eq for TransientState<T>
impl<T: NonLocalValue> NonLocalValue for TransientState<T>
impl<T: OperationValue> OperationValue for TransientState<T>
Auto Trait Implementations§
impl<T> !Freeze for TransientState<T>
impl<T> !RefUnwindSafe for TransientState<T>
impl<T> Send for TransientState<T>where
T: Send,
impl<T> Sync for TransientState<T>where
T: Send,
impl<T> Unpin for TransientState<T>where
T: Unpin,
impl<T> !UnwindSafe for TransientState<T>
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
§impl<T> DynPartialEq for T
impl<T> DynPartialEq for T
fn dyn_partial_eq(&self, other: &(dyn Any + 'static)) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§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>
Converts
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>
Converts
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§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.