Enum ocaml::Value

source ·
pub enum Value {
    Root(Root),
    Raw(Value),
}
Expand description

Value wraps the native OCaml value type

Variants§

§

Root(Root)

Rooted value

§

Raw(Value)

Reference to a rooted value NOTE: Value::Raw should NOT be used to convert arbitrary sys::Value into Value

Implementations§

Get raw OCaml value

Helper function to convert from Value to T

Helper function to convert from Value to T

Returns a named value registered by OCaml

Allocate a new value with the given size and tag.

Allocate a new float array

Allocate a new tuple value

Allocate a new small value with the given size and tag

Allocate a new value with a finalizer

This calls caml_alloc_final under-the-hood, which can has less than ideal performance behavior. In most cases you should prefer Pointer::alloc_custom when possible.

Allocate custom value

Allocate an abstract pointer value, it is best to ensure the value is on the heap using Box::into_raw(Box::from(...)) to create the pointer and Box::from_raw to free it

Create a new Value from an existing OCaml value

Get array length

See caml_register_global_root

Set caml_remove_global_root

Get the tag for the underlying OCaml value

Convert a boolean to OCaml value

Allocate and copy a string value

Allocate and copy a byte array value

Convert from a pointer to an OCaml string back to an OCaml value

Safety

This function assumes that the str argument has been allocated by OCaml

Convert from a pointer to an OCaml string back to an OCaml value

Safety

This function assumes that the &[u8] argument has been allocated by OCaml

OCaml Some value

OCaml None value

OCaml Unit value

Create a variant value

Result.Ok value

Convert OCaml ('a, 'b) Result.t to Rust Result<Value, Value>

Result.Error value

Create an OCaml int

Create an OCaml int

Create an OCaml Int64 from i64

Create an OCaml Int32 from i32

Create an OCaml Nativeint from isize

Create an OCaml Float from f64

Check if a Value is an integer or block, returning true if the underlying value is a block

Check if a Value is an integer or block, returning true if the underlying value is an integer

Get index of underlying OCaml block value

Get index of underlying OCaml double array value

Set index of underlying OCaml block value

Set index of underlying OCaml double array value

Convert an OCaml int to isize

Convert an OCaml Float to f64

Store f64 in OCaml Float

Convert an OCaml Int32 to i32

Convert an OCaml Int64 to i64

Convert an OCaml Nativeint to isize

Get pointer to data stored in an OCaml custom value

Get mutable pointer to data stored in an OCaml custom value

Get pointer to the pointer contained by Value

Get mutable pointer to the pointer contained by Value

Get underlying string pointer

Get underlying bytes pointer

Get mutable string pointer

Get mutable bytes pointer

Extract OCaml exception

Call a closure with a single argument, returning an exception result

Call a closure with two arguments, returning an exception result

Call a closure with three arguments, returning an exception result

Call a closure with n arguments, returning an exception result

Call a closure with a variable number of arguments, returning and exception Result

Modify an OCaml value in place

Modify an OCaml value in place using a raw OCaml value as the new value

Determines if the current value is an exception

Get hash variant as OCaml value

Get object method

Returns the next item and the next Seq.t if available, otherwise Ok(None)

Convert an OCaml exception value to the string representation

Initialize OCaml value using caml_initialize

This will recursively clone any OCaml value The new value is allocated inside the OCaml heap, and may end up being moved or garbage collected.

This will recursively clone any OCaml value The new value is allocated outside of the OCaml heap, and should only be used for storage inside Rust structures.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Convert from OCaml value.
Convert from OCaml value
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Convert to OCaml value.
Convert to OCaml value. Return an already rooted value as BoxRoot<T>.
Convert to OCaml 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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
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.