use crate::error::Result;
use serde::{Deserialize, Serialize};
pub trait Storable: Sized {
fn to_bytes(&self) -> Result<Vec<u8>>;
fn from_bytes(bytes: &[u8]) -> Result<Self>;
const MAX_SIZE: u32;
const FIXED_SIZE: Option<u32> = None;
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StateVersion {
pub version: u32,
pub created_at: u64,
}
pub trait Migratable: Storable {
fn current_version() -> u32;
fn migrate_from(version: u32, data: &[u8]) -> Result<Self>;
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StateMetadata {
pub version: StateVersion,
pub size_bytes: u64,
pub last_modified: u64,
}