Struct ocaml_interop::OCamlRuntime
source · [−]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
sourceimpl OCamlRuntime
impl OCamlRuntime
sourcepub fn init() -> Self
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.
sourcepub fn init_persistent()
pub fn init_persistent()
Initializes the OCaml runtime.
After the first invocation, this method does nothing.
sourcepub unsafe fn recover_handle() -> &'static mut Self
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.
sourcepub fn releasing_runtime<T, F>(&mut self, f: F) -> T where
F: FnOnce() -> T,
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.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for OCamlRuntime
impl Send for OCamlRuntime
impl Sync for OCamlRuntime
impl Unpin for OCamlRuntime
impl UnwindSafe for OCamlRuntime
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more