Skip to main content

hexz_cli/cmd/data/
store.rs

1//! Store a safetensors file as a Hexz archive.
2
3use anyhow::Result;
4use hexz_ops::safetensors::{SafetensorsStoreConfig, store_safetensors};
5use std::path::PathBuf;
6
7/// Execute the `hexz store` command.
8pub fn run(
9    input: PathBuf,
10    output: PathBuf,
11    base: Option<PathBuf>,
12    compression: String,
13    block_size: u32,
14    silent: bool,
15) -> Result<()> {
16    let config = SafetensorsStoreConfig {
17        input,
18        output: output.clone(),
19        base,
20        compression,
21        block_size,
22        show_progress: !silent,
23    };
24
25    let summary = store_safetensors(config)?;
26
27    if !silent {
28        println!(
29            "Stored {} tensor(s): {:.2} MB in → {:.2} MB out ({:.1}s)",
30            summary.tensors,
31            summary.total_bytes as f64 / 1_048_576.0,
32            summary.stored_bytes as f64 / 1_048_576.0,
33            summary.elapsed_secs,
34        );
35        println!("Archive: {:?}", output);
36    }
37
38    Ok(())
39}