KeiSeiKit-1.0/_primitives/_rust/kei-hibernate/src/inspector.rs
Parfii-bot a4e667de10 KeiSeiKit-public — clean state
Single-commit clean baseline after security scrub of niche-tells,
project codenames, internal jargon, and contributor-email leaks.

Contents:
- 100 Rust crates (_primitives/_rust/)
- 37 agent manifests (_manifests/) + generated specs (_generated/)
- 67 user-invocable skills (skills/)
- 33 hooks (hooks/)
- Composition blocks (_blocks/)
- Documentation (docs/, README.md)
- TS adapter packages (_ts_packages/)
- Assembler (_assembler/)
- Roles (_roles/)
- Templates (_templates/)
- Forgejo CI (.forgejo/)

Author: Denis Parfionovich <info@greendragon.info>

License: see LICENSE.
2026-05-01 12:09:03 +08:00

42 lines
1.3 KiB
Rust

//! Inspector — read-only preview of bundle contents.
//!
//! Streams the archive, counts non-manifest entries, and returns
//! paths from the manifest (pre-computed, order-preserving). No
//! extraction, no side effects.
use crate::error::Error;
use crate::importer::read_manifest;
use crate::manifest::MANIFEST_FILENAME;
use std::path::Path;
#[derive(Debug, Clone)]
pub struct InspectReport {
pub version: String,
pub timestamp: i64,
pub machine_id: String,
pub file_count: usize,
pub total_bytes: u64,
pub paths: Vec<String>,
}
/// List bundle contents without extracting. Rejects missing manifest
/// (same invariant as `import`). `MANIFEST_FILENAME` itself is not
/// included in the reported list.
pub fn inspect(bundle: &Path) -> Result<InspectReport, Error> {
let manifest = read_manifest(bundle)?;
let paths: Vec<String> = manifest
.entries
.iter()
.map(|e| e.path.clone())
.filter(|p| p != MANIFEST_FILENAME)
.collect();
let total_bytes = manifest.entries.iter().map(|e| e.size).sum();
Ok(InspectReport {
version: manifest.version,
timestamp: manifest.timestamp,
machine_id: manifest.machine_id,
file_count: paths.len(),
total_bytes,
paths,
})
}