Skip to main content

hexz_core/api/
mod.rs

1//! Public API for snapshot file access.
2//!
3//! This module provides the high-level API for reading Hexz snapshot archives.
4//! It re-exports the primary types used by applications and libraries to interact
5//! with `.hxz` files.
6//!
7//! # Primary Types
8//!
9//! - `File`: Main handle for reading snapshots
10//! - `SnapshotStream`: Logical stream identifier (Disk or Memory)
11//!
12//! See the `file` submodule for these types.
13//!
14//! # Usage Example
15//!
16//! ```no_run
17//! use hexz_core::api::file::{File, SnapshotStream};
18//! use hexz_core::store::local::FileBackend;
19//! use hexz_core::algo::compression::lz4::Lz4Compressor;
20//! use std::sync::Arc;
21//!
22//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
23//! // Open a snapshot
24//! let backend = Arc::new(FileBackend::new("vm.hxz".as_ref())?);
25//! let compressor = Box::new(Lz4Compressor::new());
26//! let snap = File::new(backend, compressor, None)?;
27//!
28//! // Read from disk stream
29//! let data = snap.read_at(SnapshotStream::Disk, 0, 512)?;
30//! println!("First sector: {:?}", &data[..64]);
31//! # Ok(())
32//! # }
33//! ```
34//!
35//! # Design Philosophy
36//!
37//! The API is designed to be:
38//! - **Simple**: Most operations need only `File` and `SnapshotStream`
39//! - **Flexible**: Pluggable backends, compressors, and encryptors
40//! - **Safe**: All operations return `Result<T>` with clear error types
41//! - **Efficient**: Minimal copies, buffer reuse, parallel decompression
42
43/// High-level snapshot file API.
44///
45/// Exposes `File` and related types that present logical disk and memory
46/// streams backed by the on-disk snapshot format.
47pub mod file;