use serde::{Deserialize, Serialize};
use thiserror::Error;
use crate::{NodeId, NodeRecord, RelationshipId, RelationshipRecord};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SnapshotPayload {
pub next_node_id: NodeId,
pub next_rel_id: RelationshipId,
pub nodes: Vec<NodeRecord>,
pub relationships: Vec<RelationshipRecord>,
}
impl SnapshotPayload {
pub fn empty() -> Self {
Self {
next_node_id: 0,
next_rel_id: 0,
nodes: Vec::new(),
relationships: Vec::new(),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct SnapshotMeta {
pub format_version: u32,
pub node_count: usize,
pub relationship_count: usize,
pub wal_lsn: Option<u64>,
}
#[derive(Debug, Error)]
pub enum SnapshotError {
#[error("snapshot I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("snapshot payload could not be decoded: {0}")]
Decode(String),
#[error("snapshot payload could not be encoded: {0}")]
Encode(String),
}