Trait ocaml_interop::FromOCaml
source · pub unsafe trait FromOCaml<T> {
// Required method
fn from_ocaml(v: OCaml<'_, T>) -> Self;
}
Expand description
Implements conversion from OCaml values into Rust values.
§Safety
Implementing this trait involves unsafe code that interacts with the OCaml runtime. Implementors must adhere to the following safety guidelines:
-
Valid OCaml Values: The OCaml value passed to the
from_ocaml
function must be valid. The implementor is responsible for ensuring that the value is a correct and valid representation of the typeT
in OCaml. Passing an invalid or unrelated value may lead to undefined behavior. -
Handling of OCaml Exceptions: If the OCaml code can raise exceptions, the implementor must ensure these are appropriately handled. Uncaught OCaml exceptions should not be allowed to propagate into the Rust code, as they are not compatible with Rust’s error handling mechanisms.
Implementors of this trait need to have a thorough understanding of the OCaml runtime, especially regarding value representation and memory management, to ensure safe and correct conversions from OCaml to Rust.
Required Methods§
sourcefn from_ocaml(v: OCaml<'_, T>) -> Self
fn from_ocaml(v: OCaml<'_, T>) -> Self
Convert from OCaml value.