choco_solver_sys/lib.rs
1//! Low-level Rust FFI bindings for the Choco Solver native C API.
2//!
3//! This crate exposes the generated bindings for `libchoco_capi`, the native library
4//! produced for Choco Solver. It is the unsafe boundary used by the higher-level Rust
5//! API in this repository. Most users should prefer the top-level crate instead of
6//! depending on `choco-solver-sys` directly.
7//!
8//! # What This Crate Contains
9//!
10//! - Auto-generated `bindgen` output for `libchoco_capi.h`
11//! - A generated dynamic symbol loader, exposed as [`libchoco_capi`]
12//! - Re-exported raw FFI types, constants, and functions from the generated bindings
13//!
14//! # Building The Native Library
15//!
16//! This crate does not build `libchoco_capi` for you. To produce the native library,
17//! see `BUILDING.md` in the repository root or the upstream `choco-solver-capi`
18//! project.
19//!
20//! # Safety
21//!
22//! The API exposed by this crate is intentionally low-level and mostly unsafe:
23//!
24//! - Function signatures are raw FFI declarations generated from the C header
25//! - Dynamically loaded symbols must only be called with valid pointers and values
26//! - Lifetime and thread-safety guarantees are determined by the native library, not
27//! by Rust types in this crate
28//!
29//! # Example
30//!
31//! ```no_run
32//! use choco_solver_sys::{libchoco_capi, library_filename};
33//!
34//! fn main() -> Result<(), Box<dyn std::error::Error>> {
35//! let library_path = if cfg!(target_os = "windows") {
36//! library_filename("libchoco_capi")
37//! } else {
38//! library_filename("choco_capi")
39//! };
40//!
41//! let api = unsafe { libchoco_capi::new(&library_path)? };
42//!
43//! // Generated loaders store each symbol lookup result on the struct.
44//! let create_isolate = api.graal_create_isolate.as_ref()?;
45//! let _ = create_isolate;
46//!
47//! Ok(())
48//! }
49//! ```
50mod bindings;
51pub use bindings::*;
52
53/// Builds a platform-specific dynamic library filename.
54///
55/// This is re-exported from `libloading` as a convenience when loading
56/// `libchoco_capi` dynamically.
57pub use libloading::library_filename;