pub enum CuLatchedStateUpdate<T: Clone> {
NoChange,
Set(T),
Clear,
}Expand description
Producer-side update for a stateful value cached by downstream consumers.
Use this when a value is logically “sticky” across cycles, but you still want its evolution to be explicit in the message stream. A typical producer pattern is:
- emit
Self::Setwhen the value first becomes available or changes - emit
Self::NoChangeon cycles where the previously latched value remains valid - emit
Self::Clearwhen the cached value must be invalidated
Each consumer that cares about the value should keep a local CuLatchedState and
apply incoming updates to it. Copper does not implicitly retain or replay the previous
payload for you; the state transition is part of the payload itself.
NoChange is intentionally the first variant so its bincode discriminant is zero.
§Examples
use cu29_runtime::payload::{CuLatchedState, CuLatchedStateUpdate};
let mut calibration = CuLatchedState::default();
calibration.update(&CuLatchedStateUpdate::Set(42u32));
assert_eq!(calibration.get(), Some(&42));
calibration.update(&CuLatchedStateUpdate::NoChange);
assert_eq!(calibration.get(), Some(&42));
calibration.update_owned(CuLatchedStateUpdate::Clear);
assert!(calibration.is_unset());Variants§
NoChange
Leave the consumer-side cache unchanged for this cycle.
Set(T)
Replace the consumer-side cache with a new value.
Clear
Remove the consumer-side cached value.
Implementations§
Source§impl<T: Clone> CuLatchedStateUpdate<T>
impl<T: Clone> CuLatchedStateUpdate<T>
Trait Implementations§
Source§impl<'__de, T, __Context> BorrowDecode<'__de, __Context> for CuLatchedStateUpdate<T>where
T: BorrowDecode<'__de, __Context> + Clone,
impl<'__de, T, __Context> BorrowDecode<'__de, __Context> for CuLatchedStateUpdate<T>where
T: BorrowDecode<'__de, __Context> + Clone,
Source§fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>(
decoder: &mut __D,
) -> Result<Self, DecodeError>
fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>( decoder: &mut __D, ) -> Result<Self, DecodeError>
Attempt to decode this type with the given BorrowDecode.
Source§impl<T: Clone + Clone> Clone for CuLatchedStateUpdate<T>
impl<T: Clone + Clone> Clone for CuLatchedStateUpdate<T>
Source§fn clone(&self) -> CuLatchedStateUpdate<T>
fn clone(&self) -> CuLatchedStateUpdate<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T, __Context> Decode<__Context> for CuLatchedStateUpdate<T>
impl<T, __Context> Decode<__Context> for CuLatchedStateUpdate<T>
Source§impl<T: Clone> Default for CuLatchedStateUpdate<T>
impl<T: Clone> Default for CuLatchedStateUpdate<T>
Source§fn default() -> CuLatchedStateUpdate<T>
fn default() -> CuLatchedStateUpdate<T>
Returns the “default value” for a type. Read more
Source§impl<'de, T> Deserialize<'de> for CuLatchedStateUpdate<T>where
T: Deserialize<'de> + Clone,
impl<'de, T> Deserialize<'de> for CuLatchedStateUpdate<T>where
T: Deserialize<'de> + Clone,
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
Source§impl<T> Encode for CuLatchedStateUpdate<T>
impl<T> Encode for CuLatchedStateUpdate<T>
Source§impl<T: Clone> From<T> for CuLatchedStateUpdate<T>
impl<T: Clone> From<T> for CuLatchedStateUpdate<T>
Source§impl<T> Serialize for CuLatchedStateUpdate<T>
impl<T> Serialize for CuLatchedStateUpdate<T>
Source§impl<T: Clone> TypePath for CuLatchedStateUpdate<T>
impl<T: Clone> TypePath for CuLatchedStateUpdate<T>
impl<T: Clone> StructuralPartialEq for CuLatchedStateUpdate<T>
Auto Trait Implementations§
impl<T> Freeze for CuLatchedStateUpdate<T>where
T: Freeze,
impl<T> RefUnwindSafe for CuLatchedStateUpdate<T>where
T: RefUnwindSafe,
impl<T> Send for CuLatchedStateUpdate<T>where
T: Send,
impl<T> Sync for CuLatchedStateUpdate<T>where
T: Sync,
impl<T> Unpin for CuLatchedStateUpdate<T>where
T: Unpin,
impl<T> UnsafeUnpin for CuLatchedStateUpdate<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for CuLatchedStateUpdate<T>where
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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