pub struct OCamlRuntime { /* private fields */ }
Expand description

OCaml runtime handle.

Should be initialized once at the beginning of the program and the obtained handle passed around.

Once the handle is dropped, the OCaml runtime will be shutdown.

Implementations§

source§

impl OCamlRuntime

source

pub fn init() -> Self

Initializes the OCaml runtime and returns an OCaml runtime handle.

Once the handle is dropped, the OCaml runtime will be shutdown.

source

pub fn init_persistent()

Initializes the OCaml runtime.

After the first invocation, this method does nothing.

source

pub unsafe fn recover_handle() -> &'static mut Self

Recover the runtime handle.

This method is used internally, do not use directly in code, only when writing tests.

§Safety

This function is unsafe because the OCaml runtime handle should be obtained once upon initialization of the OCaml runtime and then passed around. This method exists only to ease the authoring of tests.

source

pub fn releasing_runtime<T, F>(&mut self, f: F) -> T
where F: FnOnce() -> T,

Release the OCaml runtime lock, call f, and re-acquire the OCaml runtime lock.

source

pub fn get<'tmp, T>(&'tmp self, reference: OCamlRef<'_, T>) -> OCaml<'tmp, T>

Returns the OCaml valued to which this GC tracked reference points to.

Trait Implementations§

source§

impl Drop for OCamlRuntime

source§

fn drop(&mut self)

Executes the destructor for this type. 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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.