Skip to main content

write_layer

Function write_layer 

Source
pub fn write_layer(
    base_image: &Path,
    root: &Path,
    config: &WriteConfig,
) -> Result<WriteArtifact, WriteError>
Expand description

Pack a directory tree as a layer on top of a base image.

Produces a .lim image whose drops are split into two sets:

  • Local drops — chunks in root whose DropId is NOT in base_image’s drop set. These are compressed and stored in the layer’s own slabs exactly as write_directory_with_config would store them.
  • Referenced drops — chunks whose DropId IS in the base. These are recorded only as PendingSlice references (so the metadata tree links them in); no slab bytes are emitted in the layer. The reader resolves them via the overlay chain.

The resulting manifest carries a delta_linkage section pointing at the base image’s ManifestRoot, so any reader that supports overlay chains can extract the layer standalone or stacked on the base.

§Determinism

write_layer is deterministic given the same base_image, the same root content, and the same config. Two runs produce byte-identical layer images.

§Errors

Returns WriteError::Io on read failure or any writer-pipeline error.

§Example

use limnifs_write::{write_layer, profile};

let base = std::path::Path::new("base.lim");
let root = std::path::Path::new("./new-content");
let cfg = profile::balanced();
let artifact = write_layer(base, root, &cfg).expect("layer");
// artifact.bytes is the layer manifest; slabs contain only NEW drops.