pub fn run(snap: PathBuf, json: bool) -> Result<()>Expand description
Executes the info command to display snapshot metadata.
Reads and parses the snapshot header and master index, then displays comprehensive metadata about the snapshot’s format, compression, features, and storage statistics. Output can be formatted as human-readable text or JSON for machine consumption.
§Arguments
snap- Path to the.stsnapshot file to inspectjson- If true, output JSON format; otherwise, human-readable format
§Output Details
Human-Readable Format: Displays formatted output with sections for Features and Storage Statistics, using human-friendly byte sizes (e.g., “10.5 GB”) and clearly labeled fields.
JSON Format: Outputs a single JSON object with fields:
path: Snapshot file path (string)version: Format version number (integer)compression: Compression algorithm (“Lz4” or “Zstd”)block_size: Block size in bytes (integer)encrypted: Encryption status (boolean)has_disk: Disk stream present (boolean)has_memory: Memory stream present (boolean)variable_blocks: CDC chunking enabled (boolean)original_size: Uncompressed size in bytes (integer)compressed_size: File size in bytes (integer)compression_ratio: Compression multiplier (float)index_offset: Master index byte offset (integer)disk_pages: Number of disk index pages (integer)memory_pages: Number of memory index pages (integer)
§Errors
Returns an error if:
- The snapshot file cannot be opened (file not found, permission denied)
- The header cannot be read (file too small, I/O error)
- The header format is invalid (corrupted file, wrong format)
- The master index cannot be read (corrupted index, truncated file)
- The master index format is invalid (version mismatch, corrupted data)
§Examples
use std::path::PathBuf;
use hexz_cli::cmd::data::info;
// Display human-readable snapshot information
info::run(PathBuf::from("snapshot.hxz"), false)?;
// Output JSON for automated processing
info::run(PathBuf::from("snapshot.hxz"), true)?;