1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! Raw FFI bindings for the Lean 4 C ABI.
//!
//! **Calling any function in this crate is `unsafe`.** Prefer the safe front
//! door in [`lean-rs`](https://docs.rs/lean-rs)—specifically its `host`,
//! `module`, and `error` modules—for almost all use cases. Raw FFI is the
//! escape hatch for embedders who need it.
//!
//! Raw functions inherit Lean's C ABI ownership rules:
//! - `lean_obj_arg` is **owned** (caller transfers a refcount).
//! - `b_lean_obj_arg` is **borrowed** (caller retains the refcount).
//! - `lean_obj_res` returns an **owned** reference.
//!
//! [`lean_object`] is intentionally opaque: it is zero-sized and `!Send +
//! !Sync + !Unpin`. Downstream code reaches refcount, tag, and payload state
//! only through this crate's `pub unsafe fn` helpers, never by reading
//! fields. The crate's layout assumptions are pinned at build time: `build.rs`
//! computes the SHA-256 of the active toolchain's `include/lean/lean.h` and
//! requires it to match one entry in [`SUPPORTED_TOOLCHAINS`]. The matched
//! entry's first `versions` field is then exposed at runtime via
//! [`consts::LEAN_RESOLVED_VERSION`].
//!
//! Layering:
//! - Inline mirrors of `lean.h`'s `static inline` helpers live alongside the
//! `extern "C"` declarations for the matching category (e.g. refcount,
//! string, array). Each `pub unsafe fn` carries a `# Safety` section, each
//! `unsafe { ... }` block carries a `// SAFETY:` comment.
//! - A crate-private `repr` module defines the Lean object layout
//! (`LeanObjectRepr` and friends). These types are intentionally not
//! re-exported.
//!
//! See `crates/lean-rs-sys/README.md` for the supported Lean version window
//! and `docs/bump-toolchain.md` for the procedure to extend it.
pub
pub use ;
pub use ;