# API
```rust
pub use kcode_rust_source::File;
pub struct Lib {
pub files: Vec<File>,
// private repository and publication state
}
pub fn create(
root: impl AsRef<Path>,
name: &str,
crates_io_token: impl AsRef<str>,
) -> Result<Lib>;
pub fn open(
root: impl AsRef<Path>,
name: &str,
crates_io_token: impl AsRef<str>,
) -> Result<Lib>;
pub fn docs(root: impl AsRef<Path>, name: &str) -> Result<(String, String)>;
impl Lib {
pub fn write(&mut self) -> Result<()>;
pub fn check(&self) -> Result<()>;
pub fn publish(&self) -> Result<()>;
}
```
`kcode-rust-libs-v2` 2.0.0 is the six-operation consumer facade over neutral source validation, immutable repository generations, and disposable validation/publication tooling.
- `create` creates a minimal Rust 2024 library at version `0.1.0`.
- `open` returns the complete current-generation UTF-8 source in canonical path order, excluding ephemeral `Cargo.lock`.
- `docs` returns the package version and root `Documentation.md`.
- `write` commits `files` as the complete replacement. Omitted files are deleted. Reopen after a `stale_snapshot` error.
- `check` formats a disposable copy and runs globally quiet Cargo fetch, rustfmt, build, Clippy, all-target tests, and documentation tests. Rustfmt-repairable differences are accepted without changing managed source.
- `publish` repeats validation and publishes the formatted disposable source through Cargo’s token credential provider.
The embedded rootless Podman image includes Chromium for managed Web-library tests. Chromium’s incompatible nested process sandbox is disabled only inside that hardened container. Failed commands preserve complete stdout and stderr; publication diagnostics redact the crates.io token.
Only immutable-generation repositories selected by `HEAD` are supported. Flat legacy and partial layouts fail closed without migration or mutation. Existing current-generation repositories remain compatible.
`root` is the managed-libraries directory. The token is retained privately and used only by `publish`.