Skip to main content

LeanModule

Struct LeanModule 

Source
pub struct LeanModule<'lean, 'lib> { /* private fields */ }
Expand description

A Lean module that has been linked and initialized successfully.

Holds a borrow of its source LeanLibrary; the 'lib lifetime keeps the dylib loaded while any LeanModule referring to it is alive. The 'lean lifetime is inherited from the library, which inherits it from the crate::LeanRuntime borrow that anchored the whole chain. Neither Send nor Sync (inherited from the &LeanLibrary field).

Implementations§

Source§

impl<'lean, 'lib> LeanModule<'lean, 'lib>

Source

pub fn exported<Args, R>( &self, name: &str, ) -> LeanResult<LeanExported<'lean, 'lib, Args, R>>
where Args: LeanArgs<'lean>, R: DecodeCallResult<'lean>,

Look up a typed handle for the named exported symbol.

Args is a tuple of Rust argument types whose arity matches the Lean export’s parameter count (use () for nullary exports); each element must implement LeanAbi. R is the return decoder: either a LeanAbi type (pure path) or LeanIo<T> for an IO α-returning export.

§Errors

Returns LeanError::Host with stage HostStage::Link if:

  • the symbol is not exported by this module’s library;
  • the symbol is a Lean nullary-constant global (data-section symbol) and Args::ARITY > 0 — the function-vs-global mismatch is diagnosed at lookup so the next .call cannot SIGBUS;
  • the symbol is a Lean nullary-constant global and R is LeanIo<_> — globals are never IO-returning in Lean, so the decoder cannot apply.
Source§

impl<'lean, 'lib> LeanModule<'lean, 'lib>

Source

pub fn module_name(&self) -> &str

Human-readable package::Module.Path form for diagnostics.

The format matches what crate::module::LeanLibrary::initialize_module accepted, so log messages and test assertions can round-trip the name a caller used.

Trait Implementations§

Source§

impl Debug for LeanModule<'_, '_>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'lean, 'lib> Freeze for LeanModule<'lean, 'lib>

§

impl<'lean, 'lib> RefUnwindSafe for LeanModule<'lean, 'lib>

§

impl<'lean, 'lib> !Send for LeanModule<'lean, 'lib>

§

impl<'lean, 'lib> !Sync for LeanModule<'lean, 'lib>

§

impl<'lean, 'lib> Unpin for LeanModule<'lean, 'lib>

§

impl<'lean, 'lib> UnsafeUnpin for LeanModule<'lean, 'lib>

§

impl<'lean, 'lib> UnwindSafe for LeanModule<'lean, 'lib>

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