Skip to content

Commit

Permalink
Merge pull request #20 from containers/release
Browse files Browse the repository at this point in the history
Move main lib docs into README.md && release
  • Loading branch information
jeckersb authored Sep 20, 2024
2 parents 86e1c25 + 6c08139 commit a41c6bc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 39 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "ocidir"
description = "A Rust library for reading and writing OCI (opencontainers) layout directories"
version = "0.3.0"
version = "0.3.1"
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/containers/ocidir-rs"
Expand Down
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,36 @@

[crates-badge]: https://img.shields.io/crates/v/ocidir.svg
[crates-url]: https://crates.io/crates/ocidir
[![docs.rs](https://docs.rs/ocidir/badge.svg)](https://docs.rs/ocidir)

A low level Rust library for reading and writing
[OCI directories](https://github.com/opencontainers/image-spec/).
# 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_or_else(|| anyhow!("missing Image Index"))?);
# Ok(())
# }
```

[cap-std]: https://docs.rs/cap-std/
[OCI images]: https://github.com/opencontainers/image-spec
37 changes: 1 addition & 36 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,39 +1,4 @@
//! # 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.
//!
//! ## Getting started
//!
//! 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_or_else(|| anyhow!("missing Image Index"))?);
//! # Ok(())
//! # }
//! ```
//!
//! Users of this crate are likely to want to perform low-level manipulations
//! such as synthesizing tar layers; [`OciDir::push_layer`] for example can
//! be used for this.
//!
//! [cap-std]: https://docs.rs/cap-std/
//! [OCI images]: https://github.com/opencontainers/image-spec
//!
#![doc = include_str!("../README.md")]

use cap_std::fs::{Dir, DirBuilderExt};
use cap_std_ext::cap_tempfile;
Expand Down

0 comments on commit a41c6bc

Please sign in to comment.