Struct ocaml_interop::OCaml[][src]

pub struct OCaml<'a, T: 'a> { /* fields omitted */ }
Expand description

Representation of OCaml values.

Implementations

Obtains an OCamlRef<T> for this value.

Gets the raw representation for this value reference (pointer or int).

Safety

The resulting raw pointer will not be tracked, and may become invalid after any call into the OCaml runtime. Great care must be taken when working with these values.

Converts this OCaml value into a Rust value.

Meant to match Data_custom_val from mlvalues.h

Experimental

Safety

Casts to an arbitrary pointer type, take care before dereferencing

Similar to raw(), the resulting pointer can become invalid after any call into the OCaml runtime, for example allocating OCaml values or calling OCaml functions

Build an OCaml value wrapping a Rust value

The returned value will be opaque to the OCaml side, though you can provide functions using it and expose them to OCaml.

It will be dropped if it stops being referenced by the GC.

Experimental

Returns a value that represent OCaml’s unit value.

Returns a value that represent OCaml’s None value.

Returns an [u8] reference to the internal bytes of this value.

Returns a str reference to the internal bytes of this value.

Panics

Panics if the bytes do not form a valid utf8 string.

Returns a str reference to the internal bytes of this value.

Safety

No checks are performed to ensure that the returned value is a valid utf8 string.

Returns an [u8] reference to the internal bytes of this value.

Returns a str reference to the internal bytes of this value.

Panics

Panics if the bytes do not form a valid utf8 string.

Returns a str reference to the internal bytes of this value.

Safety

No checks are performed to ensure that the returned value is a valid utf8 string.

Converts an OCaml int to an i64.

Creates an OCaml int from an i64 without checking that it fits in an OCaml fixnum.

Safety

OCaml ints are represented as 63bits + 1bit tag, so when converting from an i64, a bit of precision is lost.

Creates an OCaml int from an i32.

Converts an OCaml boolean into a Rust boolean.

Creates an OCaml boolean from a Rust boolean.

Returns true if this OCaml option value is an OCaml None.

Returns true if this OCaml option value is an OCaml Some.

Converts an OCaml Option<T> value into a Rust Option<OCaml<T>>.

Returns true if this OCaml result value is an OCaml Ok.

Returns true if this OCaml result value is an OCaml Error.

Converts an OCaml Result<T, E> value into a Rust Result<OCaml<T>, OCaml<E>>.

Returns an OCaml nil (empty list) value.

Returns true if the value is OCaml’s nil (empty list).

Returns the head of an OCaml list.

Returns the tail of an OCaml list.

Returns a tuple of the head and tail of an OCaml list.

Trait Implementations

Immutably borrows from an owned value. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

The resulting type after dereferencing.

Dereferences the value.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.