Expand description
Rust bindings to Lean 4’s C API
Functions and comments manually translated from those in the lean.h
header provided with Lean 4
Re-exports§
pub use array::*;
pub use closure::*;
pub use constructor::*;
pub use dbg::*;
pub use external::*;
pub use init::*;
pub use int::*;
pub use io::*;
pub use libuv::*;
pub use nat::*;
pub use primitive::*;
pub use sarray::*;
pub use share_common::*;
pub use string::*;
pub use task::*;
pub use thread::*;
pub use thunk::*;
Modules§
- alloc
- array
- closure
- Closures
- constructor
- Constructor objects
- dbg
- Debugging helper functions
- external
- External objects
- init
- Utilities for initializing Lean’s runtime
- int
- Integers
- io
- IO Helper functions
- libuv
- nat
- Natural numbers
- panic
- primitive
- Primitive operations
- sarray
- Array of scalars
- share_
common - string
- Strings
- task
- Tasks
- thread
- Utilities for initializing Lean threads
- thunk
- Thunks
Structs§
- Incomplete
Array Field - lean_
array_ object - Array arrays
- lean_
closure_ object - lean_
ctor_ object - lean_
external_ class - lean_
external_ object - lean_
object - Lean object header.
- lean_
ref_ object - lean_
sarray_ object - Scalar arrays
- lean_
string_ object - lean_
task - Object of type
Task _
. The lifetime of alean_task
object can be represented as a state machine with atomic state transitions. - lean_
task_ imp - Data required for executing a Lean task. It is released as soon as the task terminates even if the task object itself is still referenced.
- lean_
thunk_ object
Constants§
- LEAN_
CLOSURE_ MAX_ ARGS - LEAN_
MAX_ CTOR_ FIELDS - LEAN_
MAX_ CTOR_ SCALARS_ SIZE - LEAN_
MAX_ SMALL_ OBJECT_ SIZE - LEAN_
OBJECT_ SIZE_ DELTA - LEAN_
SMALL_ ALLOCATOR - Lean
Array - Lean
Closure - Lean
External - LeanMPZ
- Lean
MaxCtor Tag - LeanRef
- Lean
Reserved - Lean
Scalar Array - Lean
String - Lean
Struct Array - Lean
Task - Lean
Thunk
Functions§
- c_
int_ ⚠load - layout_
compat - lean_
align - lean_
alloc_ ⚠ctor_ memory - lean_
alloc_ ⚠object - lean_
alloc_ ⚠small - lean_
alloc_ ⚠small_ object - lean_
box - Box a
usize
into alean_object
- lean_
dec ⚠ - lean_
dec_ ⚠ref - lean_
dec_ ⚠ref_ cold - lean_
free_ ⚠object - lean_
free_ ⚠small - lean_
free_ ⚠small_ object - lean_
get_ ⚠rc_ mt_ addr - lean_
get_ slot_ idx - lean_
has_ ⚠rc - Whether an object is reference counted
- lean_
inc ⚠ - lean_
inc_ ⚠heartbeat - lean_
inc_ ⚠n - lean_
inc_ ⚠ref - lean_
inc_ ⚠ref_ cold - lean_
inc_ ⚠ref_ n - lean_
inc_ ⚠ref_ n_ cold - lean_
internal_ ⚠panic - lean_
internal_ ⚠panic_ out_ of_ memory - lean_
internal_ ⚠panic_ rc_ overflow - lean_
internal_ ⚠panic_ unreachable - lean_
is_ ⚠array - lean_
is_ big_ object_ tag - lean_
is_ ⚠closure - lean_
is_ ⚠ctor - lean_
is_ ⚠exclusive - lean_
is_ ⚠exclusive_ obj - lean_
is_ ⚠external - lean_
is_ ⚠mpz - lean_
is_ ⚠mt - Whether an object is multi-threaded
- lean_
is_ ⚠persistent - lean_
is_ ⚠ref - lean_
is_ ⚠sarray - lean_
is_ scalar - Whether this lean object is a scalar
- lean_
is_ ⚠shared - lean_
is_ ⚠st - Whether an object is single-threaded
- lean_
is_ ⚠string - lean_
is_ ⚠task - lean_
is_ ⚠thunk - lean_
mark_ ⚠mt - lean_
mark_ ⚠persistent - lean_
obj_ ⚠tag - lean_
object_ ⚠byte_ size - The object size may be slightly bigger for constructor objects.
The runtime does not track the size of the scalar size area.
All constructor objects are “small”, and allocated into pages.
We retrieve their size by accessing the page header. The size of
small objects is a multiple of
LEAN_OBJECT_SIZE_DELTA
- lean_
object_ ⚠data_ byte_ size - Returns the size of the salient part of an object’s storage, i.e. the parts that contribute to the value representation; padding or unused capacity is excluded. Operations that read from an object’s storage must only access these parts, since the non-salient parts may not be initialized.
- lean_
panic_ ⚠fn - lean_
ptr_ ⚠other - lean_
ptr_ ⚠tag - lean_
set_ ⚠exit_ on_ panic - lean_
set_ ⚠non_ heap_ header - Remark: we don’t need a reference counter for objects that are not stored in the heap. Thus, we use the area to store the object size for small objects.
- lean_
set_ ⚠non_ heap_ header_ for_ big lean_set_non_heap_header
for (potentially) big objects such as arrays and strings.- lean_
set_ ⚠panic_ messages - Enable/disable panic messages
- lean_
set_ ⚠st_ header - lean_
small_ ⚠mem_ size - lean_
small_ ⚠object_ size - lean_
to_ ⚠array - lean_
to_ ⚠closure - lean_
to_ ⚠ctor - lean_
to_ ⚠external - lean_
to_ ⚠ref - lean_
to_ ⚠sarray - lean_
to_ ⚠string - lean_
to_ ⚠task - lean_
to_ ⚠thunk - lean_
unbox - Unbox a
lean_object
into ausize
- relaxed_
rc_ ⚠load - Perform a relaxed load of the reference counter of
o
, which must be a pointer into a validlean_object
Type Aliases§
- b_
lean_ obj_ arg - Borrowed object argument
- b_
lean_ obj_ res - Borrowed object result
- lean_
external_ finalize_ proc - lean_
external_ foreach_ proc - lean_
obj_ arg - Standard object argument
- lean_
obj_ res - Standard object result
- lean_
task_ object - u_
lean_ obj_ arg - Unique (aka non shared) object argument