Skip to main content

Module api

Module api 

Source
Expand description

Public API surface for reading snapshot files.

Contains the main entry point for opening and reading snapshots.

See api::file module for the main types. Public API for snapshot file access.

This module provides the high-level API for reading Hexz snapshot archives. It re-exports the primary types used by applications and libraries to interact with .hxz files.

§Primary Types

  • File: Main handle for reading snapshots
  • SnapshotStream: Logical stream identifier (Disk or Memory)

See the file submodule for these types.

§Usage Example

use hexz_core::api::file::{File, SnapshotStream};
use hexz_core::store::local::FileBackend;
use hexz_core::algo::compression::lz4::Lz4Compressor;
use std::sync::Arc;

// Open a snapshot
let backend = Arc::new(FileBackend::new("vm.hxz".as_ref())?);
let compressor = Box::new(Lz4Compressor::new());
let snap = File::new(backend, compressor, None)?;

// Read from disk stream
let data = snap.read_at(SnapshotStream::Disk, 0, 512)?;
println!("First sector: {:?}", &data[..64]);

§Design Philosophy

The API is designed to be:

  • Simple: Most operations need only File and SnapshotStream
  • Flexible: Pluggable backends, compressors, and encryptors
  • Safe: All operations return Result<T> with clear error types
  • Efficient: Minimal copies, buffer reuse, parallel decompression

Modules§

file
High-level snapshot file API.