Skip to main content

tilo_actions/remote/
session_state.rs

1//! Where a caller's workspace and this device's writes stand on the session that serves it,
2//! typed: what a program waits for instead of asking again on a timer.
3
4use serde::{Deserialize, Serialize};
5
6/// Where a joined workspace stands on this device's session with its provider.
7#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
8#[serde(rename_all = "snake_case")]
9pub enum WorkspaceState {
10    /// The session holds no connection to the workspace's provider right now.
11    Connecting,
12    /// Connected and subscribed: the provider has not said the workspace is ready yet.
13    Admitting,
14    /// The provider said it is ready: what it replayed is in this device's replica, and what this
15    /// device writes goes through.
16    Open,
17    /// Open, and the workspace's governance admits this device: its records read as a
18    /// member's and its apps answer this device's actions.
19    Serving,
20}
21
22/// Whether what this device wrote is with its provider.
23#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
24#[serde(rename_all = "snake_case", tag = "state")]
25pub enum SyncState {
26    /// Every write this device made is durable on its provider.
27    Done,
28    /// `pending` writes wait for their provider's answer.
29    Behind { pending: usize },
30}
31
32/// Where the caller's workspace and this device's writes stand.
33#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
34pub struct SessionState {
35    pub workspace: WorkspaceState,
36    pub sync: SyncState,
37}