https://github.com/containers/ocidir-rs
Low level Rust library for working with OCI (opencontainers) directories
https://github.com/containers/ocidir-rs
Last synced: 11 months ago
JSON representation
Low level Rust library for working with OCI (opencontainers) directories
- Host: GitHub
- URL: https://github.com/containers/ocidir-rs
- Owner: containers
- License: apache-2.0
- Created: 2024-06-01T22:07:20.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-07-09T23:07:30.000Z (12 months ago)
- Last Synced: 2025-07-10T08:57:57.951Z (12 months ago)
- Language: Rust
- Size: 83 KB
- Stars: 10
- Watchers: 8
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# ocidir
[![Crates.io][crates-badge]][crates-url]
[crates-badge]: https://img.shields.io/crates/v/ocidir.svg
[crates-url]: https://crates.io/crates/ocidir
[](https://docs.rs/ocidir)
# Read and write to OCI image layout directories
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.
## Dependency on cap-std
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.
## Examples
To access an existing OCI directory:
```rust,no_run
# 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(())
# }
```
[cap-std]: https://docs.rs/cap-std/
[OCI images]: https://github.com/opencontainers/image-spec