Expand description
Typed error boundary for the safe lean-rs surface.
Every fallible public function returns LeanResult<T>. LeanError
is the single error type that crosses the boundary; it has three
variants:
LeanError::LeanExceptionwhen Lean threw through itsIOerror channel. The payload reports theIO.Errorconstructor asLeanExceptionKindand a boundedmessage()that callers may surface to end users.LeanError::Hostwhen our stack failed (init, ABI conversion, contained callback panic, future link/load, internal invariant). The payload reports theHostStageand a bounded developer-facingmessage().LeanError::Cancelledwhen alean-rs-hostcooperative cancellation token was observed before an FFI dispatch or between bulk dispatches.
Bounded messages are a structural invariant: LeanException and
HostFailure have private fields, and the only constructors are
pub(crate); both run a shared helper that truncates the message at
LEAN_ERROR_MESSAGE_LIMIT on a UTF-8 char boundary. LeanCancelled
also has private fields and carries a fixed host-authored message.
External callers receive LeanError values but cannot mint one with
an unbounded message.
The rule callers learn: runtime / host failures are LeanError;
application semantics are values. A Lean function returning
IO (Except E T) decodes as LeanResult<Result<T, E>> — outer IO
failure becomes a LeanError::LeanException, inner Except
becomes a Rust Result.
§Diagnostic codes
Every error-bearing type on the public surface projects to a stable
LeanDiagnosticCode via .code(). The code names the failure
family a downstream caller must react to — Linking, Elaboration,
Unsupported, and so on — independent of the internal HostStage
tag. The as_str() form of each code is the identifier used by the
tracing spans and the published docs/diagnostics.md catalogue;
variant names and string ids are stable across patch releases.
Structs§
- Captured
Event - One captured tracing event.
- Diagnostic
Capture - Buffered tracing-event collector for the current thread.
- Host
Failure - A host-stack failure observed inside
lean-rs. - Lean
Cancelled - A cooperative cancellation observed by
lean-rs-host. - Lean
Exception - A Lean exception thrown through the
IOerror channel.
Enums§
- Host
Stage - What the host stack was doing when it failed.
- Lean
Diagnostic Code - Stable, caller-facing classification of a
lean-rsfailure. - Lean
Error - Errors reported across the safe
lean-rsboundary. - Lean
Exception Kind - Constructor tag for Lean’s
IO.Error.
Constants§
- DIAGNOSTIC_
CAPTURE_ DEFAULT_ CAPACITY - Soft cap on the number of events a
DiagnosticCaptureretains. - LEAN_
ERROR_ MESSAGE_ LIMIT - Hard cap on the byte length of any
LeanErrormessage.
Type Aliases§
- Lean
Result - Result alias used by every fallible public API in
lean-rs.