#[non_exhaustive]pub enum ReactiveStateV0 {
Available(ReactiveValueV0),
Unavailable(ReactiveUnavailableV0),
}Expand description
The complete state of one node.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Available(ReactiveValueV0)
Implementations§
Source§impl ReactiveStateV0
impl ReactiveStateV0
Sourcepub fn available(value: ReactiveValueV0) -> Self
pub fn available(value: ReactiveValueV0) -> Self
Examples found in repository?
examples/performance_envelope.rs (line 19)
16fn project_counter(state: &ReactiveStateV0) -> ReactiveStateV0 {
17 match state {
18 ReactiveStateV0::Available(ReactiveValueV0::Counter(value)) => {
19 ReactiveStateV0::available(ReactiveValueV0::Counter(value.rotate_left(7)))
20 }
21 _ => ReactiveStateV0::unavailable("counterRequired", "expected a counter deposit"),
22 }
23}
24
25fn settle(engine: &mut ReactiveEngineV0) -> Result<(), Box<dyn Error>> {
26 loop {
27 if matches!(
28 engine.stabilize_step(4_096)?,
29 StabilizeStatusV0::Settled { .. }
30 ) {
31 return Ok(());
32 }
33 }
34}
35
36fn graph() -> Result<(ReactiveEngineV0, Vec<ReactiveNodeIdV0>), Box<dyn Error>> {
37 let policy = ChangePolicyV0::exact("performanceSemanticValue");
38 let mut graph = ReactiveGraphBuilderV0::new();
39 let mut inputs = Vec::with_capacity(INPUT_COUNT);
40 let mut projections = Vec::with_capacity(INPUT_COUNT);
41 for index in 0..INPUT_COUNT {
42 let input = graph.add_input(
43 ReactiveStateV0::available(ReactiveValueV0::Counter(index as u64)),
44 policy,
45 );
46 inputs.push(input);
47 projections.push((
48 format!("projection-{index}"),
49 graph.add_map(input, project_counter, policy),
50 ));
51 }
52 let fold = graph.add_delta_fold(projections, policy)?;
53 let boundary = graph.add_effect_boundary(fold, "performance-observation", policy);
54 let mut engine = graph.build()?;
55 engine.observe(boundary)?;
56 settle(&mut engine)?;
57 engine.drain_effect_receipts();
58 Ok((engine, inputs))
59}
60
61fn measure(changes_input: bool) -> Result<Vec<Duration>, Box<dyn Error>> {
62 let (mut engine, inputs) = graph()?;
63 let mut samples = Vec::with_capacity(EVENT_COUNT);
64 for event in 0..EVENT_COUNT {
65 let index = event % INPUT_COUNT;
66 let value = if changes_input {
67 (index + event + 1) as u64
68 } else {
69 index as u64
70 };
71 let started = Instant::now();
72 engine.deposit(
73 inputs[index],
74 ReactiveStateV0::available(ReactiveValueV0::Counter(value)),
75 )?;
76 settle(&mut engine)?;
77 engine.drain_effect_receipts();
78 samples.push(started.elapsed());
79 }
80 Ok(samples)
81}Trait Implementations§
Source§impl Clone for ReactiveStateV0
impl Clone for ReactiveStateV0
Source§fn clone(&self) -> ReactiveStateV0
fn clone(&self) -> ReactiveStateV0
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ReactiveStateV0
impl Debug for ReactiveStateV0
impl Eq for ReactiveStateV0
Source§impl Ord for ReactiveStateV0
impl Ord for ReactiveStateV0
Source§fn cmp(&self, other: &ReactiveStateV0) -> Ordering
fn cmp(&self, other: &ReactiveStateV0) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialEq for ReactiveStateV0
impl PartialEq for ReactiveStateV0
Source§impl PartialOrd for ReactiveStateV0
impl PartialOrd for ReactiveStateV0
impl StructuralPartialEq for ReactiveStateV0
Auto Trait Implementations§
impl Freeze for ReactiveStateV0
impl RefUnwindSafe for ReactiveStateV0
impl Send for ReactiveStateV0
impl Sync for ReactiveStateV0
impl Unpin for ReactiveStateV0
impl UnsafeUnpin for ReactiveStateV0
impl UnwindSafe for ReactiveStateV0
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