# API
```rust
pub struct File {
pub path: String,
pub contents: String,
}
pub struct Lib {
pub files: Vec<File>,
// private fields
}
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<()>;
}
```
- `create` creates a minimal Rust 2024 library at version `0.1.0`.
- `open` returns the complete UTF-8 source, excluding `Cargo.lock`. It automatically migrates a valid library stored by `kcode-rust-libs` v1.
- `docs` returns the package version and `Documentation.md`.
- `write` commits `files` as the complete replacement. Omitted files are deleted. Reopen after a `stale_snapshot` error.
- `check` validates the current in-memory source.
- `publish` rechecks and publishes the current in-memory source.
`root` is the managed-libraries directory. The token is the crates.io registry token used only by `publish`.