use crate::core::{State, StateHistory};
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
pub mod error;
pub use error::CheckpointError;
pub const CHECKPOINT_VERSION: u32 = 1;
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct MachineMetadata {
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub current_attempt: usize,
pub total_attempts: HashMap<String, usize>,
}
impl Default for MachineMetadata {
fn default() -> Self {
let now = Utc::now();
Self {
created_at: now,
updated_at: now,
current_attempt: 0,
total_attempts: HashMap::new(),
}
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(bound = "")]
pub struct Checkpoint<S: State> {
pub version: u32,
pub id: String,
pub timestamp: DateTime<Utc>,
pub initial_state: S,
pub current_state: S,
pub history: StateHistory<S>,
pub metadata: MachineMetadata,
}