Expand description
A byte-exact writer of composefs EROFS images, with an fs-verity hasher.
A caller builds a tree of directories, symlinks, and regular files. The
crate writes the EROFS image of the tree and returns the fs-verity digest of
the image. The image is byte-identical to the composefs image of the
ostree command, format version 0. The crate is synchronous and does not
read a repository.
§Entry points
Directoryis the root of a tree, andNodeis one entry of it.Metadataholds the mode, the owner, the mtime, and the xattrs of a node.Contentis the content of aRegularfile: empty or a loose object.build_imagewrites the image into anImagein memory.write_image_towrites the image through a sink and does not keep it.FsVerityHashercalculates an fs-verity digest of a byte stream.Erroris the error of the two image writers.
§Examples
use ostrya_composefs::{Content, Directory, FsVerityHasher, Metadata, Node, Regular};
let mut root = Directory::new(Metadata { mode: 0o755, ..Metadata::default() });
let meta = Metadata { mode: 0o644, ..Metadata::default() };
root.insert("empty", Node::Regular(Regular { meta, content: Content::Empty }));
let image = ostrya_composefs::build_image(&root)?;
assert_eq!(FsVerityHasher::hash(&image.bytes), image.fs_verity);
// The streaming writer writes the same bytes and returns the same digest.
let mut sink = Vec::new();
assert_eq!(ostrya_composefs::write_image_to(&root, &mut sink)?, image.fs_verity);
assert_eq!(sink, image.bytes);Structs§
- Directory
- A directory and its named children.
- FsVerity
Hasher - A streaming fs-verity hasher (SHA-256, 4096-byte blocks, no salt).
- Image
- A composefs EROFS image in memory, with its fs-verity digest.
- Metadata
- The logical metadata of a node.
- Regular
- A regular file.
- Symlink
- A symbolic link, with its target inline in the image.
Enums§
- Content
- The content of a
Regularfile in the image. - Error
- The error of
build_imageandwrite_image_to. - Node
- A node in the tree.
Functions§
- build_
image - Writes the composefs EROFS image of the tree at
rootinto memory. - write_
image_ to - Writes the composefs EROFS image of the tree at
rootthroughout.