Skip to main content

CargoLeanCapability

Struct CargoLeanCapability 

Source
pub struct CargoLeanCapability { /* private fields */ }
Expand description

Build-script helper for shipping a Rust crate with bundled Lean code.

This is the canonical downstream build.rs entry point. It composes emit_lean_link_directives_checked, build_lake_target, and the cargo:rustc-env=... directives that carry a JSON artifact manifest and a backward-compatible dylib path into Rust code at compile time.

fn main() -> Result<(), Box<dyn std::error::Error>> {
    lean_toolchain::CargoLeanCapability::new("lean", "MyCapability")
        .package("my_app")
        .module("MyCapability")
        .build()?;
    Ok(())
}

Implementations§

Source§

impl CargoLeanCapability

Source

pub fn new( project_root: impl Into<PathBuf>, target_name: impl Into<String>, ) -> Self

Create a build helper for a Lake project and lean_lib target.

Source

pub fn package(self, package: impl Into<String>) -> Self

Set the Lake package name used by the module initializer.

If omitted, the helper infers the package from lake-manifest.json or lakefile.lean, matching build_lake_target.

Source

pub fn module(self, module: impl Into<String>) -> Self

Set the root Lean module name initialized by Rust.

Defaults to the Lake target name.

Source

pub fn env_var(self, env_var: impl Into<String>) -> Self

Override the generated Cargo environment variable name.

The default is LEAN_RS_CAPABILITY_<TARGET>_DYLIB, with the target converted to screaming snake case.

Source

pub fn manifest_env_var(self, env_var: impl Into<String>) -> Self

Override the generated Cargo environment variable name for the artifact manifest.

The default is LEAN_RS_CAPABILITY_<TARGET>_MANIFEST, with the target converted to screaming snake case.

Source

pub fn build(self) -> Result<BuiltLeanCapability, LinkDiagnostics>

Emit link directives, build the Lake shared library, write the artifact manifest, and emit cargo:rustc-env directives for the manifest and compatibility dylib path.

§Errors

Returns LinkDiagnostics if Lean cannot be discovered, Lake cannot build the target, or the target output cannot be resolved.

Source

pub fn build_quiet(self) -> Result<BuiltLeanCapability, LinkDiagnostics>

Same as Self::build without printing Cargo directives.

This exists for tests and internal callers. Downstream build.rs scripts should use Self::build.

§Errors

Returns LinkDiagnostics if Lake cannot build the target or the target output cannot be resolved.

Trait Implementations§

Source§

impl Clone for CargoLeanCapability

Source§

fn clone(&self) -> CargoLeanCapability

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CargoLeanCapability

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.