kcode-rust-bins 3.0.0

Author, locally publish, and run small Rust binaries
Documentation
# API

```rust
pub struct File {
    pub path: String,
    pub contents: String,
}

pub struct RunRequest {
    pub text: String,
    pub objects: Vec<Vec<u8>>,
}

pub struct RunResult {
    pub version: String,
    pub text: String,
    pub objects: Vec<Vec<u8>>,
    pub diagnostics: 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>,
    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 integrating server
resolves model-facing object references before `run` and saves returned byte
objects afterward; this crate has no object-store dependency.