pub struct LeanExported<'lean, 'lib, Args, R> { /* private fields */ }Expand description
A typed handle for an exported Lean symbol.
Holds a resolved symbol address (function or persistent global) and
the runtime borrow that anchors any Obj it produces. Construction
goes exclusively through
LeanModule::exported; the
handle borrows from its source LeanModule via 'lib so neither
the library nor the runtime can be dropped while a handle is live.
Args is a tuple of Rust argument types whose elements implement
LeanAbi; the LeanArgs impl for that tuple supplies the
arity. R is the return type, satisfying DecodeCallResult.
Neither Send nor Sync: the contained runtime reference and
the *mut symbol address both propagate the per-thread restriction.
Implementations§
Source§impl<'lean, Args, R> LeanExported<'lean, '_, Args, R>
impl<'lean, Args, R> LeanExported<'lean, '_, Args, R>
Sourcepub unsafe fn from_function_address(
runtime: &'lean LeanRuntime,
address: *mut c_void,
) -> Self
pub unsafe fn from_function_address( runtime: &'lean LeanRuntime, address: *mut c_void, ) -> Self
Build a function-targeted typed handle from a pre-resolved symbol address.
LeanModule::exported is the normal lookup path; this constructor
exists so external opinionated host stacks (e.g. lean-rs-host’s
LeanCapabilities) can pre-resolve a capability dylib’s function
symbols once at load time via LeanLibrary::resolve_function_symbol
and then dispatch through cached addresses without re-dlsym-ing
per call. It always produces a Function-targeted handle — global
symbols still go through LeanModule::exported.
§Safety
The caller must guarantee all of the following:
addressis the entry point of a function in a library that outlives'lib(typically a&'lib LeanLibrary<'lean>).- The function’s C ABI matches the requested
Args/Rshape under Lake’s emission conventions (per-argLeanAbi::CRepr, per-resultDecodeCallResult::CRepr). runtimeis the witness for'lean.
Source§impl<'lean, 'lib, R> LeanExported<'lean, 'lib, (), R>where
R: DecodeCallResult<'lean>,
impl<'lean, 'lib, R> LeanExported<'lean, 'lib, (), R>where
R: DecodeCallResult<'lean>,
Sourcepub fn call(&self) -> LeanResult<R::Output>
pub fn call(&self) -> LeanResult<R::Output>
Invoke the exported symbol and decode the result.
§Errors
Returns LeanError::LeanException when the underlying
Lean export raises through IO (only possible when R
is LeanIo<_>). Returns LeanError::Host with stage
HostStage::Conversion when the return value does not
decode into the declared R type.
Source§impl<'lean, 'lib, A1, R> LeanExported<'lean, 'lib, (A1,), R>where
A1: LeanAbi<'lean>,
R: DecodeCallResult<'lean>,
impl<'lean, 'lib, A1, R> LeanExported<'lean, 'lib, (A1,), R>where
A1: LeanAbi<'lean>,
R: DecodeCallResult<'lean>,
Sourcepub fn call(&self, a1: A1) -> LeanResult<R::Output>
pub fn call(&self, a1: A1) -> LeanResult<R::Output>
Invoke the exported symbol and decode the result.
§Errors
Returns LeanError::LeanException when the underlying
Lean export raises through IO (only possible when R
is LeanIo<_>). Returns LeanError::Host with stage
HostStage::Conversion when the return value does not
decode into the declared R type.
Source§impl<'lean, 'lib, A1, A2, R> LeanExported<'lean, 'lib, (A1, A2), R>
impl<'lean, 'lib, A1, A2, R> LeanExported<'lean, 'lib, (A1, A2), R>
Sourcepub fn call(&self, a1: A1, a2: A2) -> LeanResult<R::Output>
pub fn call(&self, a1: A1, a2: A2) -> LeanResult<R::Output>
Invoke the exported symbol and decode the result.
§Errors
Returns LeanError::LeanException when the underlying
Lean export raises through IO (only possible when R
is LeanIo<_>). Returns LeanError::Host with stage
HostStage::Conversion when the return value does not
decode into the declared R type.
Source§impl<'lean, 'lib, A1, A2, A3, R> LeanExported<'lean, 'lib, (A1, A2, A3), R>
impl<'lean, 'lib, A1, A2, A3, R> LeanExported<'lean, 'lib, (A1, A2, A3), R>
Sourcepub fn call(&self, a1: A1, a2: A2, a3: A3) -> LeanResult<R::Output>
pub fn call(&self, a1: A1, a2: A2, a3: A3) -> LeanResult<R::Output>
Invoke the exported symbol and decode the result.
§Errors
Returns LeanError::LeanException when the underlying
Lean export raises through IO (only possible when R
is LeanIo<_>). Returns LeanError::Host with stage
HostStage::Conversion when the return value does not
decode into the declared R type.
Source§impl<'lean, 'lib, A1, A2, A3, A4, R> LeanExported<'lean, 'lib, (A1, A2, A3, A4), R>where
A1: LeanAbi<'lean>,
A2: LeanAbi<'lean>,
A3: LeanAbi<'lean>,
A4: LeanAbi<'lean>,
R: DecodeCallResult<'lean>,
impl<'lean, 'lib, A1, A2, A3, A4, R> LeanExported<'lean, 'lib, (A1, A2, A3, A4), R>where
A1: LeanAbi<'lean>,
A2: LeanAbi<'lean>,
A3: LeanAbi<'lean>,
A4: LeanAbi<'lean>,
R: DecodeCallResult<'lean>,
Sourcepub fn call(&self, a1: A1, a2: A2, a3: A3, a4: A4) -> LeanResult<R::Output>
pub fn call(&self, a1: A1, a2: A2, a3: A3, a4: A4) -> LeanResult<R::Output>
Invoke the exported symbol and decode the result.
§Errors
Returns LeanError::LeanException when the underlying
Lean export raises through IO (only possible when R
is LeanIo<_>). Returns LeanError::Host with stage
HostStage::Conversion when the return value does not
decode into the declared R type.
Source§impl<'lean, 'lib, A1, A2, A3, A4, A5, R> LeanExported<'lean, 'lib, (A1, A2, A3, A4, A5), R>
impl<'lean, 'lib, A1, A2, A3, A4, A5, R> LeanExported<'lean, 'lib, (A1, A2, A3, A4, A5), R>
Sourcepub fn call(
&self,
a1: A1,
a2: A2,
a3: A3,
a4: A4,
a5: A5,
) -> LeanResult<R::Output>
pub fn call( &self, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, ) -> LeanResult<R::Output>
Invoke the exported symbol and decode the result.
§Errors
Returns LeanError::LeanException when the underlying
Lean export raises through IO (only possible when R
is LeanIo<_>). Returns LeanError::Host with stage
HostStage::Conversion when the return value does not
decode into the declared R type.
Source§impl<'lean, 'lib, A1, A2, A3, A4, A5, A6, R> LeanExported<'lean, 'lib, (A1, A2, A3, A4, A5, A6), R>
impl<'lean, 'lib, A1, A2, A3, A4, A5, A6, R> LeanExported<'lean, 'lib, (A1, A2, A3, A4, A5, A6), R>
Sourcepub fn call(
&self,
a1: A1,
a2: A2,
a3: A3,
a4: A4,
a5: A5,
a6: A6,
) -> LeanResult<R::Output>
pub fn call( &self, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, ) -> LeanResult<R::Output>
Invoke the exported symbol and decode the result.
§Errors
Returns LeanError::LeanException when the underlying
Lean export raises through IO (only possible when R
is LeanIo<_>). Returns LeanError::Host with stage
HostStage::Conversion when the return value does not
decode into the declared R type.
Source§impl<'lean, 'lib, A1, A2, A3, A4, A5, A6, A7, R> LeanExported<'lean, 'lib, (A1, A2, A3, A4, A5, A6, A7), R>
impl<'lean, 'lib, A1, A2, A3, A4, A5, A6, A7, R> LeanExported<'lean, 'lib, (A1, A2, A3, A4, A5, A6, A7), R>
Sourcepub fn call(
&self,
a1: A1,
a2: A2,
a3: A3,
a4: A4,
a5: A5,
a6: A6,
a7: A7,
) -> LeanResult<R::Output>
pub fn call( &self, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, ) -> LeanResult<R::Output>
Invoke the exported symbol and decode the result.
§Errors
Returns LeanError::LeanException when the underlying
Lean export raises through IO (only possible when R
is LeanIo<_>). Returns LeanError::Host with stage
HostStage::Conversion when the return value does not
decode into the declared R type.
Source§impl<'lean, 'lib, A1, A2, A3, A4, A5, A6, A7, A8, R> LeanExported<'lean, 'lib, (A1, A2, A3, A4, A5, A6, A7, A8), R>
impl<'lean, 'lib, A1, A2, A3, A4, A5, A6, A7, A8, R> LeanExported<'lean, 'lib, (A1, A2, A3, A4, A5, A6, A7, A8), R>
Sourcepub fn call(
&self,
a1: A1,
a2: A2,
a3: A3,
a4: A4,
a5: A5,
a6: A6,
a7: A7,
a8: A8,
) -> LeanResult<R::Output>
pub fn call( &self, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8, ) -> LeanResult<R::Output>
Invoke the exported symbol and decode the result.
§Errors
Returns LeanError::LeanException when the underlying
Lean export raises through IO (only possible when R
is LeanIo<_>). Returns LeanError::Host with stage
HostStage::Conversion when the return value does not
decode into the declared R type.
Source§impl<'lean, 'lib, A1, A2, A3, A4, A5, A6, A7, A8, A9, R> LeanExported<'lean, 'lib, (A1, A2, A3, A4, A5, A6, A7, A8, A9), R>
impl<'lean, 'lib, A1, A2, A3, A4, A5, A6, A7, A8, A9, R> LeanExported<'lean, 'lib, (A1, A2, A3, A4, A5, A6, A7, A8, A9), R>
Sourcepub fn call(
&self,
a1: A1,
a2: A2,
a3: A3,
a4: A4,
a5: A5,
a6: A6,
a7: A7,
a8: A8,
a9: A9,
) -> LeanResult<R::Output>
pub fn call( &self, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8, a9: A9, ) -> LeanResult<R::Output>
Invoke the exported symbol and decode the result.
§Errors
Returns LeanError::LeanException when the underlying
Lean export raises through IO (only possible when R
is LeanIo<_>). Returns LeanError::Host with stage
HostStage::Conversion when the return value does not
decode into the declared R type.
Source§impl<'lean, 'lib, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, R> LeanExported<'lean, 'lib, (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10), R>
impl<'lean, 'lib, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, R> LeanExported<'lean, 'lib, (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10), R>
Sourcepub fn call(
&self,
a1: A1,
a2: A2,
a3: A3,
a4: A4,
a5: A5,
a6: A6,
a7: A7,
a8: A8,
a9: A9,
a10: A10,
) -> LeanResult<R::Output>
pub fn call( &self, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8, a9: A9, a10: A10, ) -> LeanResult<R::Output>
Invoke the exported symbol and decode the result.
§Errors
Returns LeanError::LeanException when the underlying
Lean export raises through IO (only possible when R
is LeanIo<_>). Returns LeanError::Host with stage
HostStage::Conversion when the return value does not
decode into the declared R type.
Source§impl<'lean, 'lib, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, R> LeanExported<'lean, 'lib, (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11), R>
impl<'lean, 'lib, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, R> LeanExported<'lean, 'lib, (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11), R>
Sourcepub fn call(
&self,
a1: A1,
a2: A2,
a3: A3,
a4: A4,
a5: A5,
a6: A6,
a7: A7,
a8: A8,
a9: A9,
a10: A10,
a11: A11,
) -> LeanResult<R::Output>
pub fn call( &self, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8, a9: A9, a10: A10, a11: A11, ) -> LeanResult<R::Output>
Invoke the exported symbol and decode the result.
§Errors
Returns LeanError::LeanException when the underlying
Lean export raises through IO (only possible when R
is LeanIo<_>). Returns LeanError::Host with stage
HostStage::Conversion when the return value does not
decode into the declared R type.
Source§impl<'lean, 'lib, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, R> LeanExported<'lean, 'lib, (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12), R>
impl<'lean, 'lib, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, R> LeanExported<'lean, 'lib, (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12), R>
Sourcepub fn call(
&self,
a1: A1,
a2: A2,
a3: A3,
a4: A4,
a5: A5,
a6: A6,
a7: A7,
a8: A8,
a9: A9,
a10: A10,
a11: A11,
a12: A12,
) -> LeanResult<R::Output>
pub fn call( &self, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8, a9: A9, a10: A10, a11: A11, a12: A12, ) -> LeanResult<R::Output>
Invoke the exported symbol and decode the result.
§Errors
Returns LeanError::LeanException when the underlying
Lean export raises through IO (only possible when R
is LeanIo<_>). Returns LeanError::Host with stage
HostStage::Conversion when the return value does not
decode into the declared R type.