Skip to main content

Crate simee_bundle

Crate simee_bundle 

Source
Expand description

Portable device bundles (#170).

A bundle describes a device with no host path in it: a Manifest (manifest.json) and content-addressed chunks (chunks/<aa>/<blake3>, each compressed alone with LZ4). Disk images are cut at fixed CHUNK_SIZE boundaries; all-zero chunks and holes are recorded as extents and never stored. It is a directory, or the same as one plain uncompressed tar with the manifest first, so an import streams it and checks each chunk as it arrives.

Platforms fill in the manifest’s identity and say what goes where (emu-avd for AVDs); this crate packs, unpacks and verifies: every chunk against its hash, every disk and file against its whole hash, every path (relative, no ..), and the format’s major version.

Structs§

AndroidImage
An Android system image by content: source.properties’s API level, tag, ABI and revision, the BLAKE3 of the files that boot it, and build.prop’s fingerprint.
Base
The disk a delta is against, checked by its hash before use (#171).
Captures
ChunkStore
A bundle directory’s chunks.
Contents
What goes into a bundle: disk images read from host files, and small files given whole, each at its path in the bundle.
Device
Disk
A disk image: its chunks, in order, covering size bytes.
Extent
len bytes of a disk at offset: one stored chunk (hash), zeros (all-zero data and holes, never stored; an import leaves a hole), or the same range of the base (from_base, #171).
Extracted
What Reader::extract wrote.
File
A small file (config.ini): its chunks, each Manifest::chunk_size but the last.
GuestIdentity
Manifest
Options
How to write a bundle.
Reader
An opened bundle: its manifest, read and validated, and the chunks still to read.
Secret
Summary
What an export wrote, in the terms #169 measures: the disks’ logical and allocated sizes against the bundle’s.
TarReader
Reads an archive’s regular files in order, each into memory (at most max bytes: a bundle’s entries are the manifest and chunks). Directory entries are skipped; any other kind (links, devices, extended headers) is refused.
TarWriter
Writes regular-file entries, then the two zero blocks that end an archive.

Enums§

Error
Identity
The system image (Android) a device needs. iOS’s runtime and device type come in its own variant.

Constants§

CHUNK_SIZE
Disk images are cut into chunks of this size (the last one shorter). Fixed boundaries suit disks, written in place: an offset never shifts, so content-defined chunking would find the same boundaries, and a small chunk limits what one dirty block drags into a bundle.
COLD_BOOT
What resume means in format 1: the receiver boots the disks cold (no RAM state).
COMPRESSION
The only chunk compression in format 1: each chunk is one LZ4 block (no frame or size header; the manifest gives each chunk’s length).
FORMAT
The format’s major version. A reader refuses any other: a new major may change what an existing field means. Additions that old readers can ignore keep the major.
MANIFEST
A bundle directory’s manifest file, and a bundle archive’s first entry.
MAX_MANIFEST
The largest manifest a reader accepts: a 64 GiB disk in 1 MiB chunks is ~7 MB of JSON.

Functions§

chunk_name
The name a chunk has in a bundle: chunks/<first two hex digits>/<hash>.
compress
data as one LZ4 block (no size header: the manifest gives each chunk’s length).
decompress_verified
Decompresses chunk hash into at most max bytes (a block that would decompress past it is refused) and checks it is what its name says.
export
Writes contents as a bundle at to (a .tar archive, else a new directory), with manifest’s description and identity; its chunk fields, disks and files are filled in here. Reads every disk twice: once to cut and hash it, once to compress the distinct chunks (each checked against the first pass, so a disk that changes in between fails the export).
hash
The BLAKE3 of data, as the manifest writes it.
hash_file
The BLAKE3 of the file at path, read in 1 MiB pieces (a 4.4 GB system image: ~3 s).
is_archive
Whether to names the single-file form (.tar); anything else is a directory.
is_hash
Whether h is a BLAKE3 hash as the manifest writes it: 64 lowercase hex digits.
max_compressed
The most a chunk of len bytes takes compressed (LZ4’s bound for data that doesn’t compress).
parse_chunk_name
The hash a bundle entry named like chunk_name holds, if it is named so.
read_regular
Reads bundle file path whole: a regular file (not a symlink, a device or a FIFO) of at most limit bytes, so a directory bundle can’t make a reader follow a link to /dev/zero.
safe_path
Whether path is safe to join to a destination directory: relative, /-separated, with no empty, . or .. component, no backslash and no NUL.

Type Aliases§

Result