# 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 fields
}
pub fn create(
root: impl AsRef<Path>,
name: &str,
object_store: Arc<dyn ObjectStore>,
) -> Result<Lib>;
pub fn open(
root: impl AsRef<Path>,
name: &str,
object_store: Arc<dyn ObjectStore>,
) -> 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<String>;
}
pub fn run(
object_store: &dyn ObjectStore,
binary_object_id: &str,
request: &RunRequest,
) -> 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` performs the same validation once, saves the exact executable through `ObjectStore`, and returns its object ID.
- `run` attempts to execute any supplied executable object in a disposable open-networked Podman container.
A guest calls `read_input` once and `write_output` once. Each direction carries exactly one JSON value plus ordered byte objects. Standard output is reserved for the framed response; diagnostics belong on standard error.