Skip to content

Commit f7a0a44

Browse files
committed
Move main lib docs into README.md
So our repository landing page has more useful information. Signed-off-by: Colin Walters <[email protected]>
1 parent 86e1c25 commit f7a0a44

File tree

2 files changed

+32
-38
lines changed

2 files changed

+32
-38
lines changed

README.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,34 @@
55
[crates-badge]: https://img.shields.io/crates/v/ocidir.svg
66
[crates-url]: https://crates.io/crates/ocidir
77

8-
A low level Rust library for reading and writing
9-
[OCI directories](https://github.com/opencontainers/image-spec/).
8+
# Read and write to OCI image layout directories
9+
10+
This library contains medium and low-level APIs for working with
11+
[OCI images], which are basically a directory with blobs and JSON files
12+
for metadata.
13+
14+
## Dependency on cap-std
15+
16+
This library makes use of [cap-std] to operate in a capability-oriented
17+
fashion. In practice, the code in this project is well tested and would
18+
not traverse outside its own path root. However, using capabilities
19+
is a generally good idea when operating in the container ecosystem,
20+
in particular when actively processing tar streams.
21+
22+
## Examples
23+
24+
To access an existing OCI directory:
25+
26+
```rust,no_run
27+
# use ocidir::cap_std;
28+
# use anyhow::{anyhow, Result};
29+
# fn main() -> anyhow::Result<()> {
30+
let d = cap_std::fs::Dir::open_ambient_dir("/path/to/ocidir", cap_std::ambient_authority())?;
31+
let d = ocidir::OciDir::open(&d)?;
32+
println!("{:?}", d.read_index()?.ok_or_else(|| anyhow!("missing Image Index"))?);
33+
# Ok(())
34+
# }
35+
```
36+
37+
[cap-std]: https://docs.rs/cap-std/
38+
[OCI images]: https://github.com/opencontainers/image-spec

src/lib.rs

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,4 @@
1-
//! # Read and write to OCI image layout directories
2-
//!
3-
//! This library contains medium and low-level APIs for working with
4-
//! [OCI images], which are basically a directory with blobs and JSON files
5-
//! for metadata.
6-
//!
7-
//! ## Dependency on cap-std
8-
//!
9-
//! This library makes use of [cap-std] to operate in a capability-oriented
10-
//! fashion. In practice, the code in this project is well tested and would
11-
//! not traverse outside its own path root. However, using capabilities
12-
//! is a generally good idea when operating in the container ecosystem,
13-
//! in particular when actively processing tar streams.
14-
//!
15-
//! ## Getting started
16-
//!
17-
//! To access an existing OCI directory:
18-
//!
19-
//! ```rust,no_run
20-
//! # use ocidir::cap_std;
21-
//! # use anyhow::{anyhow, Result};
22-
//! # fn main() -> anyhow::Result<()> {
23-
//! let d = cap_std::fs::Dir::open_ambient_dir("/path/to/ocidir", cap_std::ambient_authority())?;
24-
//! let d = ocidir::OciDir::open(&d)?;
25-
//! println!("{:?}", d.read_index()?.ok_or_else(|| anyhow!("missing Image Index"))?);
26-
//! # Ok(())
27-
//! # }
28-
//! ```
29-
//!
30-
//! Users of this crate are likely to want to perform low-level manipulations
31-
//! such as synthesizing tar layers; [`OciDir::push_layer`] for example can
32-
//! be used for this.
33-
//!
34-
//! [cap-std]: https://docs.rs/cap-std/
35-
//! [OCI images]: https://github.com/opencontainers/image-spec
36-
//!
1+
#![doc = include_str!("../README.md")]
372

383
use cap_std::fs::{Dir, DirBuilderExt};
394
use cap_std_ext::cap_tempfile;

0 commit comments

Comments
 (0)