Expand description
Safe Rust wrappers over [llama-cpp-sys].
Owns the FFI boundary for llama.cpp: RAII handles, typed errors, the
streaming trampoline. Downstream code (the xybrid-core adapter, Phase
2’s consumers, and any future backend that wants llama-cpp without the
xybrid-core surface) only touches the safe types in this crate.
§Activation
The real implementation lives behind the bindings cargo feature. A
default build — cargo build -p xybrid-llama — compiles this crate to
an empty shell on every target, which keeps cargo clippy --workspace
on Linux CI runners green even without a C++ toolchain.
§Public surface
LlamaModel— owning handle to a loaded GGUF modelLlamaContext— owning handle to a llama context, with KV-cache manipulation methods- [
StreamingCallback] — closure type alias for streaming generation - [
generate_streaming] / [generate_with_stops] — the autoregressive loops, including the prefix-reusen_past_inknob set_verbosity/get_verbosity— llama.cpp log-level controlLlamaError/LlamaResult— error surface
Zero unsafe appears on the public surface. Every unsafe block lives
in the [mod@ffi] module behind pub(crate) with # Safety doc
comments, mirroring xybrid-mlx::ffi’s discipline.
Structs§
- Llama
Context - Stub returned when the
bindingsfeature is disabled. - Llama
Model - Stub returned when the
bindingsfeature is disabled.
Enums§
- Llama
Error - Errors produced by the safe llama.cpp wrappers.
Functions§
- backend_
init - Initialize the llama.cpp backend and apply Xybrid’s log policy once.
- get_
verbosity - set_
verbosity
Type Aliases§
- Llama
Result - Result alias used throughout the safe wrappers.