llam 0.1.1

Safe, Go-style Rust bindings for the LLAM runtime
llam-0.1.1 has been yanked.

llam

Safe, synchronous Rust bindings for the LLAM C runtime.

llam is the only crate users need:

[dependencies]
llam = "0.1.1"

It includes safe wrappers, raw C ABI bindings under llam::sys, and a build script that installs the LLAM C SDK into Cargo's private OUT_DIR/llam-sdk prefix by default.

Example

fn main() -> llam::Result<()> {
    llam::run(|| {
        let (tx, rx) = llam::channel::bounded::<u32>(1)?;
        llam::spawn!(move {
            tx.send(42).unwrap();
        });
        assert_eq!(rx.recv()?, 42);
        Ok(())
    })
}

For I/O-heavy code:

fn main() -> llam::Result<()> {
    llam::run_with_profile(llam::Profile::IoLatency, || {
        let listener = llam::net::TcpListener::bind("127.0.0.1:9090")?;
        let (stream, peer) = listener.accept()?;
        println!("accepted {peer}");
        drop(stream);
        Ok(())
    })
}

#[llam::main] is not provided because LLAM-rs publishes only this single crate. Rust attribute macros require a separate proc-macro crate.

Build

Default:

cargo build

The build script installs LLAM C into:

target/.../build/llam-*/out/llam-sdk

Use a preinstalled SDK:

LLAM_SYS_PREFIX="$HOME/.local/llam" cargo build

Useful environment variables:

  • LLAM_SYS_PREFIX: installed LLAM SDK prefix.
  • LLAM_SYS_LIB_DIR and LLAM_SYS_INCLUDE_DIR: direct lib/include override.
  • LLAM_SYS_INSTALL_PREFIX: override automatic SDK install prefix.
  • LLAM_SYS_INSTALL_VERSION: LLAM release version. Default: 1.0.0.
  • LLAM_SYS_INSTALL_TARGET: explicit release target.
  • LLAM_SYS_NO_INSTALL=1: disable automatic install.

Modules

  • llam::run, llam::run_with_profile
  • llam::spawn!, llam::try_spawn!, JoinHandle, TaskGroup
  • llam::channel, llam::select!
  • llam::sync, llam::time, llam::blocking
  • llam::net, llam::io, llam::fs
  • llam::task_local, llam::diagnostics
  • llam::sys