1use crate::{CommandError, Value};
2use std::sync::Arc;
3use std::sync::atomic::{AtomicBool, Ordering};
4
5#[derive(Clone, Debug, PartialEq)]
7pub struct Invocation {
8 pub command: usize,
9 pub params: Vec<Value>,
10}
11
12#[derive(Clone, Copy, Debug, PartialEq, Eq)]
16pub enum CommandStatus {
17 Accepted,
18 Completed,
19}
20
21#[derive(Clone, Debug, PartialEq)]
22pub struct CommandOutcome {
23 pub status: CommandStatus,
24 pub revision: u64,
27 pub result: Result<Value, CommandError>,
28}
29
30#[derive(Clone, Debug, PartialEq)]
32pub struct StateUpdate {
33 pub revision: u64,
34 pub changes: Vec<(usize, Value)>,
35}
36
37#[derive(Clone, Debug, Default)]
41pub struct Cancellation(Arc<AtomicBool>);
42
43impl Cancellation {
44 pub fn new() -> Self {
45 Self::default()
46 }
47
48 pub fn is_cancelled(&self) -> bool {
49 self.0.load(Ordering::Relaxed)
50 }
51
52 pub fn cancel(&self) {
53 self.0.store(true, Ordering::Relaxed);
54 }
55}