Skip to main content

Lean

Struct Lean 

Source
pub struct Lean<'l> { /* private fields */ }
Expand description

A token that proves the Lean runtime is initialized.

This type is used throughout Leo3 to ensure that Lean objects are only accessed when the runtime is properly initialized. The 'l lifetime parameter ties all Lean objects to the initialization scope.

§Example

use leo3::prelude::*;

fn process_data<'l>(lean: Lean<'l>) -> LeanResult<()> {
    // Create Lean objects using the token
    let s = LeanString::mk(lean, "Hello");
    Ok(())
}

§Safety

The Lean<'l> token is typically created by with_lean() or similar functions that ensure proper initialization. Users should not create this token manually except in very specific circumstances.

Implementations§

Source§

impl<'l> Lean<'l>

Source

pub unsafe fn assume_initialized() -> Self

Create a new Lean<'l> token.

§Safety

The caller must ensure that the Lean runtime is properly initialized before calling this function. This is typically done by calling prepare_freethreaded_lean().

This function should generally not be called directly by users. Use with_lean() instead.

Source

pub fn as_ptr(self) -> *mut c_void

Get a pointer to the Lean runtime context.

This is used internally for FFI calls that require context. Most users won’t need to call this directly.

Trait Implementations§

Source§

impl<'l> Clone for Lean<'l>

Source§

fn clone(&self) -> Lean<'l>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'l> Copy for Lean<'l>

Auto Trait Implementations§

§

impl<'l> Freeze for Lean<'l>

§

impl<'l> RefUnwindSafe for Lean<'l>

§

impl<'l> !Send for Lean<'l>

§

impl<'l> !Sync for Lean<'l>

§

impl<'l> Unpin for Lean<'l>

§

impl<'l> UnwindSafe for Lean<'l>

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