ocaml_interop/
mlvalues.rs

1// Copyright (c) Viable Systems and TezEdge Contributors
2// SPDX-License-Identifier: MIT
3
4#[cfg(doc)]
5use crate::*;
6
7use core::marker::PhantomData;
8pub use ocaml_sys::{
9    extract_exception, field as field_val, is_block, is_exception_result, is_long, string_val,
10    tag_val, wosize_val, Intnat, Uintnat as UIntnat, Value as RawOCaml, EMPTY_LIST, FALSE,
11    MAX_FIXNUM, MIN_FIXNUM, NONE, TRUE, UNIT,
12};
13
14pub mod bigarray;
15pub mod tag;
16
17/// [`OCaml`]`<OCamlList<T>>` is a reference to an OCaml `list` containing
18/// values of type `T`.
19pub struct OCamlList<A> {
20    _marker: PhantomData<A>,
21}
22
23/// [`OCaml`]`<OCamlUniformArray<T>>` is a reference to an OCaml array which is
24/// guaranteed to not contain unboxed floats. If OCaml was configured with
25/// `--disable-flat-float-array` this corresponds to regular `array`s, but if
26/// not, `Uniform_array.t` in the `base` library can be used instead.
27/// See [Lexifi's blog post on the topic](https://www.lexifi.com/blog/ocaml/about-unboxed-float-arrays/)
28/// for more details.
29pub struct OCamlUniformArray<A> {
30    _marker: PhantomData<A>,
31}
32
33/// [`OCaml`]`<OCamlFloatArray<T>>` is a reference to an OCaml `floatarray`
34/// which is an array containing `float`s in an unboxed form.
35pub struct OCamlFloatArray {}
36
37/// `OCaml<DynBox<T>>` is for passing a value of type `T` to OCaml
38///
39/// To box a Rust value, use [`OCaml::box_value`][crate::OCaml::box_value].
40///
41/// **Experimental**
42pub struct DynBox<A> {
43    _marker: PhantomData<A>,
44}
45
46/// [`OCaml`]`<OCamlBytes>` is a reference to an OCaml `bytes` value.
47///
48/// # Note
49///
50/// Unlike with [`OCaml`]`<String>`, there is no validation being performed when converting this
51/// value into `String`.
52pub struct OCamlBytes {}
53
54/// [`OCaml`]`<OCamlInt>` is an OCaml integer (tagged and unboxed) value.
55pub type OCamlInt = Intnat;
56
57/// [`OCaml`]`<OCamlInt32>` is a reference to an OCaml `Int32.t` (boxed `int32`) value.
58pub struct OCamlInt32 {}
59
60/// [`OCaml`]`<OCamlInt64>` is a reference to an OCaml `Int64.t` (boxed `int64`) value.
61pub struct OCamlInt64 {}
62
63/// [`OCaml`]`<OCamlFloat>` is a reference to an OCaml `float` (boxed `float`) value.
64pub struct OCamlFloat {}
65
66/// [`OCaml`]`<OCamlException>` is a reference to an OCaml `exn` value.
67pub struct OCamlException {}