# API
```rust
pub struct File {
pub path: String,
pub contents: String,
}
pub trait ObjectStore: Send + Sync {
fn load(&self, object_id: &str) -> ObjectStoreResult<Vec<u8>>;
fn save(&self, bytes: &[u8]) -> ObjectStoreResult<String>;
}
pub struct Lib {
pub files: Vec<File>,
// private source identity and publication root
}
pub fn create(
source_root: impl AsRef<Path>,
publications_root: impl AsRef<Path>,
name: &str,
) -> Result<Lib>;
pub fn open(
source_root: impl AsRef<Path>,
publications_root: impl AsRef<Path>,
name: &str,
) -> Result<Lib>;
pub fn docs(source_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<()>;
}
pub const DEFAULT_RUN_TIMEOUT: Duration;
pub fn run(
publications_root: impl AsRef<Path>,
object_store: &dyn ObjectStore,
name: &str,
version_selector: &str,
request: &RunRequest,
timeout: Option<Duration>,
) -> Result<RunResult>;
pub fn read_input() -> Result<RustBinInput>;
pub fn write_output(output: &RustBinOutput) -> Result<()>;
```
- `create` creates a minimal Rust 2024 binary at version `0.1.0`.
- `open` returns the complete UTF-8 source, excluding `Cargo.lock`. It migrates
a valid legacy flat source repository.
- `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 and statically builds the current in-memory source.
- `publish` validates once and immutably installs the executable by package
name and exact stable version.
- `run` selects the highest stable publication matching a Cargo-compatible
selector. Prefix a complete version with `v` to require that exact version.
`None` uses the two-minute default timeout.
A guest calls `read_input` once and `write_output` once. Each direction carries
one exact UTF-8 text value plus ordered byte objects. Standard output is
reserved for the framed response; diagnostics belong on standard error.
Published executables use local publication storage. The supplied object store
is used only for call payloads.