Skip to main content

durable_streams_server/transfer/
mod.rs

1//! Export and import of stream data for backup, restore, and migration.
2//!
3//! This module provides a versioned JSON format that captures stream metadata
4//! and message payloads (base64-encoded) so they can be moved between storage
5//! backends, backed up to external systems, or restored after data loss.
6//!
7//! # Modules
8//!
9//! - [`mod@format`] — serde types for the JSON document schema
10//! - [`export`] — reads streams from storage and writes JSON
11//! - [`import`] — reads JSON and writes streams into storage
12
13pub mod export;
14pub mod format;
15pub mod import;
16
17/// Errors that can occur during export or import operations.
18#[derive(Debug, thiserror::Error)]
19pub enum TransferError {
20    /// Underlying I/O failure (file create, write, etc.).
21    #[error("I/O error: {0}")]
22    Io(#[from] std::io::Error),
23
24    /// JSON serialization or deserialization failure.
25    #[error("JSON error: {0}")]
26    Json(#[from] serde_json::Error),
27
28    /// A message payload could not be decoded from base64.
29    #[error("base64 decode error: {0}")]
30    Base64(#[from] base64::DecodeError),
31
32    /// The export document declares a format version this build cannot handle.
33    #[error("unsupported format version: {0}")]
34    UnsupportedVersion(u32),
35
36    /// A storage operation failed during export or import.
37    #[error("storage error: {0}")]
38    Storage(#[from] crate::protocol::error::Error),
39
40    /// A stream in the import already exists and the conflict policy forbids it.
41    #[error("import conflict: stream '{0}' already exists")]
42    Conflict(String),
43}