pub struct OCaml<'a, T> where
T: 'a, { /* private fields */ }
Expand description
Representation of OCaml values.
Implementations
sourceimpl<'a, T> OCaml<'a, T>
impl<'a, T> OCaml<'a, T>
sourcepub fn as_ref<'b>(&'b self) -> &'b OCamlCell<T> where
'a: 'b,
pub fn as_ref<'b>(&'b self) -> &'b OCamlCell<T> where
'a: 'b,
Obtains an OCamlRef
<T>
for this value.
pub fn root(self) -> BoxRoot<T>
sourcepub unsafe fn raw(&self) -> isize
pub unsafe fn raw(&self) -> isize
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.
sourcepub fn to_rust<RustT>(&self) -> RustT where
RustT: FromOCaml<T>,
pub fn to_rust<RustT>(&self) -> RustT where
RustT: FromOCaml<T>,
Converts this OCaml value into a Rust value.
sourcepub unsafe fn custom_ptr_val<U>(&self) -> *const U
pub unsafe fn custom_ptr_val<U>(&self) -> *const U
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
sourceimpl<'a, T> OCaml<'a, DynBox<T>> where
T: 'static,
impl<'a, T> OCaml<'a, DynBox<T>> where
T: 'static,
sourcepub fn box_value(cr: &'a mut OCamlRuntime, v: T) -> OCaml<'a, DynBox<T>>
pub fn box_value(cr: &'a mut OCamlRuntime, v: T) -> OCaml<'a, DynBox<T>>
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
sourceimpl<'a> OCaml<'a, String>
impl<'a> OCaml<'a, String>
sourcepub fn as_bytes(&self) -> &'a [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn as_bytes(&self) -> &'a [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Returns an [u8]
reference to the internal bytes of this value.
sourcepub fn as_str(&self) -> &'a str
pub fn as_str(&self) -> &'a str
Returns a str
reference to the internal bytes of this value.
Panics
Panics if the bytes do not form a valid utf8 string.
sourcepub unsafe fn as_str_unchecked(&self) -> &'a str
pub unsafe fn as_str_unchecked(&self) -> &'a str
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.
sourceimpl<'a> OCaml<'a, OCamlBytes>
impl<'a> OCaml<'a, OCamlBytes>
sourcepub fn as_bytes(&self) -> &'a [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn as_bytes(&self) -> &'a [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Returns an [u8]
reference to the internal bytes of this value.
sourcepub fn as_str(&self) -> &'a str
pub fn as_str(&self) -> &'a str
Returns a str
reference to the internal bytes of this value.
Panics
Panics if the bytes do not form a valid utf8 string.
sourcepub unsafe fn as_str_unchecked(&self) -> &'a str
pub unsafe fn as_str_unchecked(&self) -> &'a str
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.
sourceimpl<'a> OCaml<'a, isize>
impl<'a> OCaml<'a, isize>
sourcepub unsafe fn of_i64_unchecked(n: i64) -> OCaml<'static, isize>
pub unsafe fn of_i64_unchecked(n: i64) -> OCaml<'static, isize>
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.
pub fn of_i64(
n: i64
) -> Result<OCaml<'static, isize>, OCamlFixnumConversionError>
sourceimpl<'a, A, B, C, D, E> OCaml<'a, (A, B, C, D, E)>
impl<'a, A, B, C, D, E> OCaml<'a, (A, B, C, D, E)>
pub fn to_tuple(
&self
) -> (OCaml<'a, A>, OCaml<'a, B>, OCaml<'a, C>, OCaml<'a, D>, OCaml<'a, E>)
pub fn fst(&self) -> OCaml<'a, A>
pub fn snd(&self) -> OCaml<'a, B>
pub fn tuple_3(&self) -> OCaml<'a, C>
pub fn tuple_4(&self) -> OCaml<'a, D>
pub fn tuple_5(&self) -> OCaml<'a, E>
sourceimpl<'a, A, B, C, D, E, F> OCaml<'a, (A, B, C, D, E, F)>
impl<'a, A, B, C, D, E, F> OCaml<'a, (A, B, C, D, E, F)>
pub fn to_tuple(
&self
) -> (OCaml<'a, A>, OCaml<'a, B>, OCaml<'a, C>, OCaml<'a, D>, OCaml<'a, E>, OCaml<'a, F>)
pub fn fst(&self) -> OCaml<'a, A>
pub fn snd(&self) -> OCaml<'a, B>
pub fn tuple_3(&self) -> OCaml<'a, C>
pub fn tuple_4(&self) -> OCaml<'a, D>
pub fn tuple_5(&self) -> OCaml<'a, E>
pub fn tuple_6(&self) -> OCaml<'a, F>
sourceimpl<'a, A, B, C, D, E, F, G> OCaml<'a, (A, B, C, D, E, F, G)>
impl<'a, A, B, C, D, E, F, G> OCaml<'a, (A, B, C, D, E, F, G)>
pub fn to_tuple(
&self
) -> (OCaml<'a, A>, OCaml<'a, B>, OCaml<'a, C>, OCaml<'a, D>, OCaml<'a, E>, OCaml<'a, F>, OCaml<'a, G>)
pub fn fst(&self) -> OCaml<'a, A>
pub fn snd(&self) -> OCaml<'a, B>
pub fn tuple_3(&self) -> OCaml<'a, C>
pub fn tuple_4(&self) -> OCaml<'a, D>
pub fn tuple_5(&self) -> OCaml<'a, E>
pub fn tuple_6(&self) -> OCaml<'a, F>
pub fn tuple_7(&self) -> OCaml<'a, G>
sourceimpl<'a, A, B, C, D, E, F, G, H> OCaml<'a, (A, B, C, D, E, F, G, H)>
impl<'a, A, B, C, D, E, F, G, H> OCaml<'a, (A, B, C, D, E, F, G, H)>
pub fn to_tuple(
&self
) -> (OCaml<'a, A>, OCaml<'a, B>, OCaml<'a, C>, OCaml<'a, D>, OCaml<'a, E>, OCaml<'a, F>, OCaml<'a, G>, OCaml<'a, H>)
pub fn fst(&self) -> OCaml<'a, A>
pub fn snd(&self) -> OCaml<'a, B>
pub fn tuple_3(&self) -> OCaml<'a, C>
pub fn tuple_4(&self) -> OCaml<'a, D>
pub fn tuple_5(&self) -> OCaml<'a, E>
pub fn tuple_6(&self) -> OCaml<'a, F>
pub fn tuple_7(&self) -> OCaml<'a, G>
pub fn tuple_8(&self) -> OCaml<'a, H>
sourceimpl<'a, A, B, C, D, E, F, G, H, I> OCaml<'a, (A, B, C, D, E, F, G, H, I)>
impl<'a, A, B, C, D, E, F, G, H, I> OCaml<'a, (A, B, C, D, E, F, G, H, I)>
pub fn to_tuple(
&self
) -> (OCaml<'a, A>, OCaml<'a, B>, OCaml<'a, C>, OCaml<'a, D>, OCaml<'a, E>, OCaml<'a, F>, OCaml<'a, G>, OCaml<'a, H>, OCaml<'a, I>)
pub fn fst(&self) -> OCaml<'a, A>
pub fn snd(&self) -> OCaml<'a, B>
pub fn tuple_3(&self) -> OCaml<'a, C>
pub fn tuple_4(&self) -> OCaml<'a, D>
pub fn tuple_5(&self) -> OCaml<'a, E>
pub fn tuple_6(&self) -> OCaml<'a, F>
pub fn tuple_7(&self) -> OCaml<'a, G>
pub fn tuple_8(&self) -> OCaml<'a, H>
pub fn tuple_9(&self) -> OCaml<'a, I>
Trait Implementations
sourceimpl<'a, T> FromValue<'a> for OCaml<'a, T>
impl<'a, T> FromValue<'a> for OCaml<'a, T>
sourcefn from_value<'b>(v: Value) -> OCaml<'a, T>
fn from_value<'b>(v: Value) -> OCaml<'a, T>
Convert from OCaml value
sourceimpl<'a, T> IntoValue for OCaml<'a, T>
impl<'a, T> IntoValue for OCaml<'a, T>
sourcefn into_value(self, _rt: &Runtime) -> Value
fn into_value(self, _rt: &Runtime) -> Value
Convert to OCaml value
impl<'a, T> Copy for OCaml<'a, T>
Auto Trait Implementations
impl<'a, T> RefUnwindSafe for OCaml<'a, T> where
T: RefUnwindSafe,
impl<'a, T> Send for OCaml<'a, T> where
T: Sync,
impl<'a, T> Sync for OCaml<'a, T> where
T: Sync,
impl<'a, T> Unpin for OCaml<'a, T>
impl<'a, T> UnwindSafe for OCaml<'a, T> where
T: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more