Struct ocaml::Value [−][src]
pub struct Value(pub Root);
Value wraps the native OCaml value
type
Implementations
impl Value
[src]
impl Value
[src]pub unsafe fn alloc(n: usize, tag: Tag) -> Value
[src]
pub unsafe fn alloc(n: usize, tag: Tag) -> Value
[src]Allocate a new value with the given size and tag.
pub unsafe fn alloc_tuple(n: usize) -> Value
[src]
pub unsafe fn alloc_tuple(n: usize) -> Value
[src]Allocate a new tuple value
pub unsafe fn alloc_small(n: usize, tag: Tag) -> Value
[src]
pub unsafe fn alloc_small(n: usize, tag: Tag) -> Value
[src]Allocate a new small value with the given size and tag
pub unsafe fn alloc_final<T>(
finalizer: unsafe extern "C" fn(_: Raw),
cfg: Option<(usize, usize)>
) -> Value
[src]
pub unsafe fn alloc_final<T>(
finalizer: unsafe extern "C" fn(_: Raw),
cfg: Option<(usize, usize)>
) -> Value
[src]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.
pub unsafe fn alloc_custom<T: Custom>() -> Value
[src]
pub unsafe fn alloc_custom<T: Custom>() -> Value
[src]Allocate custom value
pub unsafe fn alloc_abstract_ptr<T>(ptr: *mut T) -> Value
[src]
pub unsafe fn alloc_abstract_ptr<T>(ptr: *mut T) -> Value
[src]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
pub unsafe fn array_length(&self) -> usize
[src]
pub unsafe fn array_length(&self) -> usize
[src]Get array length
pub unsafe fn register_global_root(&mut self)
[src]
pub unsafe fn register_global_root(&mut self)
[src]See caml_register_global_root
pub unsafe fn remove_global_root(&mut self)
[src]
pub unsafe fn remove_global_root(&mut self)
[src]Set caml_remove_global_root
pub unsafe fn of_str(s: &str) -> Value
[src]
pub unsafe fn of_str(s: &str) -> Value
[src]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
pub unsafe fn of_bytes(s: &[u8]) -> Value
[src]
pub unsafe fn of_bytes(s: &[u8]) -> Value
[src]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
pub unsafe fn variant(rt: &Runtime, tag: u8, value: Option<Value>) -> Value
[src]
pub unsafe fn variant(rt: &Runtime, tag: u8, value: Option<Value>) -> Value
[src]Create a variant value
pub unsafe fn is_block(&self) -> bool
[src]
pub unsafe fn is_block(&self) -> bool
[src]Check if a Value is an integer or block, returning true if the underlying value is a block
pub unsafe fn is_long(&self) -> bool
[src]
pub unsafe fn is_long(&self) -> bool
[src]Check if a Value is an integer or block, returning true if the underlying value is an integer
pub unsafe fn store_field<V: IntoValue>(
&mut self,
rt: &Runtime,
i: Size,
val: V
)
[src]
pub unsafe fn store_field<V: IntoValue>(
&mut self,
rt: &Runtime,
i: Size,
val: V
)
[src]Set index of underlying OCaml block value
pub unsafe fn nativeint_val(&self) -> isize
[src]
pub unsafe fn nativeint_val(&self) -> isize
[src]Convert an OCaml Nativeint
to isize
pub unsafe fn custom_ptr_val<T>(&self) -> *const T
[src]
pub unsafe fn custom_ptr_val<T>(&self) -> *const T
[src]Get pointer to data stored in an OCaml custom value
pub unsafe fn custom_ptr_val_mut<T>(&mut self) -> *mut T
[src]
pub unsafe fn custom_ptr_val_mut<T>(&mut self) -> *mut T
[src]Get mutable pointer to data stored in an OCaml custom value
pub unsafe fn abstract_ptr_val<T>(&self) -> *const T
[src]
pub unsafe fn abstract_ptr_val<T>(&self) -> *const T
[src]Get pointer to the pointer contained by Value
pub unsafe fn abstract_ptr_val_mut<T>(&self) -> *mut T
[src]
pub unsafe fn abstract_ptr_val_mut<T>(&self) -> *mut T
[src]Get mutable pointer to the pointer contained by Value
pub unsafe fn string_val(&self) -> &str
[src]
pub unsafe fn string_val(&self) -> &str
[src]Get underlying string pointer
pub unsafe fn string_val_mut(&mut self) -> &mut str
[src]
pub unsafe fn string_val_mut(&mut self) -> &mut str
[src]Get mutable string pointer
pub unsafe fn bytes_val_mut(&mut self) -> &mut [u8]
[src]
pub unsafe fn bytes_val_mut(&mut self) -> &mut [u8]
[src]Get mutable bytes pointer
pub unsafe fn check_result(self) -> Result<Value, Error>
[src]
pub unsafe fn check_result(self) -> Result<Value, Error>
[src]Convert value to Rust Result type depending on if the value is an exception or not
pub unsafe fn call<A: IntoValue>(
&self,
rt: &Runtime,
arg1: A
) -> Result<Value, Error>
[src]
pub unsafe fn call<A: IntoValue>(
&self,
rt: &Runtime,
arg1: A
) -> Result<Value, Error>
[src]Call a closure with a single argument, returning an exception value
pub unsafe fn call2<A: IntoValue, B: IntoValue>(
&self,
rt: &Runtime,
arg1: A,
arg2: B
) -> Result<Value, Error>
[src]
pub unsafe fn call2<A: IntoValue, B: IntoValue>(
&self,
rt: &Runtime,
arg1: A,
arg2: B
) -> Result<Value, Error>
[src]Call a closure with two arguments, returning an exception value
pub unsafe fn call3<A: IntoValue, B: IntoValue, C: IntoValue>(
&self,
rt: &Runtime,
arg1: A,
arg2: B,
arg3: C
) -> Result<Value, Error>
[src]
pub unsafe fn call3<A: IntoValue, B: IntoValue, C: IntoValue>(
&self,
rt: &Runtime,
arg1: A,
arg2: B,
arg3: C
) -> Result<Value, Error>
[src]Call a closure with three arguments, returning an exception value
pub unsafe fn call_n<A: AsRef<[Raw]>>(&self, args: A) -> Result<Value, Error>
[src]
pub unsafe fn call_n<A: AsRef<[Raw]>>(&self, args: A) -> Result<Value, Error>
[src]Call a closure with n
arguments, returning an exception value
pub unsafe fn modify<V: IntoValue>(&mut self, rt: &Runtime, v: V)
[src]
pub unsafe fn modify<V: IntoValue>(&mut self, rt: &Runtime, v: V)
[src]Modify an OCaml value in place
pub unsafe fn is_exception_result(&self) -> bool
[src]
pub unsafe fn is_exception_result(&self) -> bool
[src]Determines if the current value is an exception
pub unsafe fn hash_variant<S: AsRef<str>>(
rt: &Runtime,
name: S,
a: Option<Value>
) -> Value
[src]
pub unsafe fn hash_variant<S: AsRef<str>>(
rt: &Runtime,
name: S,
a: Option<Value>
) -> Value
[src]Get hash variant as OCaml value
pub unsafe fn method<S: AsRef<str>>(
&self,
rt: &Runtime,
name: S
) -> Option<Value>
[src]
pub unsafe fn method<S: AsRef<str>>(
&self,
rt: &Runtime,
name: S
) -> Option<Value>
[src]Get object method
pub unsafe fn initialize(&mut self, value: Value)
[src]
pub unsafe fn initialize(&mut self, value: Value)
[src]Initialize OCaml value using caml_initialize
pub unsafe fn deep_clone_to_ocaml(self) -> Self
[src]
pub unsafe fn deep_clone_to_ocaml(self) -> Self
[src]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.
pub unsafe fn deep_clone_to_rust(&self) -> Self
[src]
pub unsafe fn deep_clone_to_rust(&self) -> Self
[src]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
impl<'a, T> FromOCaml<T> for Value
[src]
impl<'a, T> FromOCaml<T> for Value
[src]fn from_ocaml(v: OCaml<'_, T>) -> Value
[src]
fn from_ocaml(v: OCaml<'_, T>) -> Value
[src]Convert from OCaml value.
impl<'a> IntoValue for &Value
[src]
impl<'a> IntoValue for &Value
[src]fn into_value(self, _rt: &Runtime) -> Value
[src]
fn into_value(self, _rt: &Runtime) -> Value
[src]Convert to OCaml value
impl PartialOrd<Value> for Value
[src]
impl PartialOrd<Value> for Value
[src]fn partial_cmp(&self, other: &Value) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Value) -> Option<Ordering>
[src]This method returns an ordering between self
and other
values if one exists. Read more
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<T> ToOCaml<T> for Value
[src]
impl<T> ToOCaml<T> for Value
[src]fn to_boxroot(&self, cr: &mut OCamlRuntime) -> BoxRoot<T>
[src]
fn to_boxroot(&self, cr: &mut OCamlRuntime) -> BoxRoot<T>
[src]Convert to OCaml value. Return an already rooted value as BoxRoot
<T>
.
impl StructuralPartialEq for Value
[src]
Auto Trait Implementations
impl RefUnwindSafe for Value
impl !Send for Value
impl !Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more