Skip to main content

LeanExported

Struct LeanExported 

Source
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_unchecked; 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, 'lib, R> LeanExported<'lean, 'lib, (), R>
where R: DecodeCallResult<'lean>,

Source

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>,

Source

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>
where A1: LeanAbi<'lean>, A2: LeanAbi<'lean>, R: DecodeCallResult<'lean>,

Source

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>
where A1: LeanAbi<'lean>, A2: LeanAbi<'lean>, A3: LeanAbi<'lean>, R: DecodeCallResult<'lean>,

Source

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>,

Source

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>
where A1: LeanAbi<'lean>, A2: LeanAbi<'lean>, A3: LeanAbi<'lean>, A4: LeanAbi<'lean>, A5: LeanAbi<'lean>, R: DecodeCallResult<'lean>,

Source

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>
where A1: LeanAbi<'lean>, A2: LeanAbi<'lean>, A3: LeanAbi<'lean>, A4: LeanAbi<'lean>, A5: LeanAbi<'lean>, A6: LeanAbi<'lean>, R: DecodeCallResult<'lean>,

Source

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>
where A1: LeanAbi<'lean>, A2: LeanAbi<'lean>, A3: LeanAbi<'lean>, A4: LeanAbi<'lean>, A5: LeanAbi<'lean>, A6: LeanAbi<'lean>, A7: LeanAbi<'lean>, R: DecodeCallResult<'lean>,

Source

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>
where A1: LeanAbi<'lean>, A2: LeanAbi<'lean>, A3: LeanAbi<'lean>, A4: LeanAbi<'lean>, A5: LeanAbi<'lean>, A6: LeanAbi<'lean>, A7: LeanAbi<'lean>, A8: LeanAbi<'lean>, R: DecodeCallResult<'lean>,

Source

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>
where A1: LeanAbi<'lean>, A2: LeanAbi<'lean>, A3: LeanAbi<'lean>, A4: LeanAbi<'lean>, A5: LeanAbi<'lean>, A6: LeanAbi<'lean>, A7: LeanAbi<'lean>, A8: LeanAbi<'lean>, A9: LeanAbi<'lean>, R: DecodeCallResult<'lean>,

Source

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>
where A1: LeanAbi<'lean>, A2: LeanAbi<'lean>, A3: LeanAbi<'lean>, A4: LeanAbi<'lean>, A5: LeanAbi<'lean>, A6: LeanAbi<'lean>, A7: LeanAbi<'lean>, A8: LeanAbi<'lean>, A9: LeanAbi<'lean>, A10: LeanAbi<'lean>, R: DecodeCallResult<'lean>,

Source

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>
where A1: LeanAbi<'lean>, A2: LeanAbi<'lean>, A3: LeanAbi<'lean>, A4: LeanAbi<'lean>, A5: LeanAbi<'lean>, A6: LeanAbi<'lean>, A7: LeanAbi<'lean>, A8: LeanAbi<'lean>, A9: LeanAbi<'lean>, A10: LeanAbi<'lean>, A11: LeanAbi<'lean>, R: DecodeCallResult<'lean>,

Source

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>
where A1: LeanAbi<'lean>, A2: LeanAbi<'lean>, A3: LeanAbi<'lean>, A4: LeanAbi<'lean>, A5: LeanAbi<'lean>, A6: LeanAbi<'lean>, A7: LeanAbi<'lean>, A8: LeanAbi<'lean>, A9: LeanAbi<'lean>, A10: LeanAbi<'lean>, A11: LeanAbi<'lean>, A12: LeanAbi<'lean>, R: DecodeCallResult<'lean>,

Source

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.

Trait Implementations§

Source§

impl<Args, R> Debug for LeanExported<'_, '_, Args, R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'lean, 'lib, Args, R> !Send for LeanExported<'lean, 'lib, Args, R>

§

impl<'lean, 'lib, Args, R> !Sync for LeanExported<'lean, 'lib, Args, R>

§

impl<'lean, 'lib, Args, R> Freeze for LeanExported<'lean, 'lib, Args, R>

§

impl<'lean, 'lib, Args, R> RefUnwindSafe for LeanExported<'lean, 'lib, Args, R>

§

impl<'lean, 'lib, Args, R> Unpin for LeanExported<'lean, 'lib, Args, R>

§

impl<'lean, 'lib, Args, R> UnsafeUnpin for LeanExported<'lean, 'lib, Args, R>

§

impl<'lean, 'lib, Args, R> UnwindSafe for LeanExported<'lean, 'lib, Args, R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more