Skip to main content

Exhume Body as a library

This page shows how to embed the exhume_body crate in your own Rust codebase. You’ll see how to add the dependency, initialise the library, and read data from an evidence file with just a few lines of code. Exhume Body is part of the wider Exhume FileSystem toolkit.

📦 Install

Create a fresh project:

cargo new body_test
cd body_test

🛠️ Adding Exhume Body as a Dependency

Update your Cargo.toml:

[dependencies]
exhume_body = "=0.3.1"

# Optional (but recommended) logging crates
log = "0.4.25"
env_logger = "0.11.6"

🏃‍♀️ Minimal Example

The snippet below opens an evidence file, prints a quick header, then reads the first 1 KiB of data.

use exhume_body::Body;
use std::io::{Read, Seek, SeekFrom};

fn main() {
// Enable log output (optional)
env_logger::Builder::new()
.filter_level(log::LevelFilter::Info)
.init();

// Open the evidence file — let Exhume auto-detect the container type
let mut body = Body::new("/path/to/evidence.E01".to_string(), "auto");

// Dump some high-level metadata to the log
body.print_info();

// Seek to byte offset 0x200
body.seek(SeekFrom::Start(0x200)).expect("seek failed");

// Read the next 0x400 bytes (1 KiB)
let mut buffer = vec![0u8; 0x400];
body.read_exact(&mut buffer).expect("read failed");

println!("Read {} bytes; first 16 bytes: {:02x?}", buffer.len(), &buffer[..16]);
}

That’s it! You now have a lightweight way to peek, carve, or stream data from forensic images directly inside your Rust applications.