Crates.io | ocidir |
lib.rs | ocidir |
version | 0.3.1 |
source | src |
created_at | 2024-06-02 13:36:54.412416 |
updated_at | 2024-09-20 20:07:14.002065 |
description | A Rust library for reading and writing OCI (opencontainers) layout directories |
homepage | |
repository | https://github.com/containers/ocidir-rs |
max_upload_size | |
id | 1259203 |
size | 47,188 |
This library contains medium and low-level APIs for working with OCI images, which are basically a directory with blobs and JSON files for metadata.
This library makes use of cap-std to operate in a capability-oriented fashion. In practice, the code in this project is well tested and would not traverse outside its own path root. However, using capabilities is a generally good idea when operating in the container ecosystem, in particular when actively processing tar streams.
To access an existing OCI directory:
# use ocidir::cap_std;
# use anyhow::{anyhow, Result};
# fn main() -> anyhow::Result<()> {
let d = cap_std::fs::Dir::open_ambient_dir("/path/to/ocidir", cap_std::ambient_authority())?;
let d = ocidir::OciDir::open(&d)?;
println!("{:?}", d.read_index()?.ok_or_else(|| anyhow!("missing Image Index"))?);
# Ok(())
# }