Struct jlrs::value::Value [−][src]
#[repr(transparent)]pub struct Value<'frame, 'data>(_, _, _);
A Value
is a wrapper around a pointer to some data owned by the Julia garbage collector, it
has two lifetimes: 'frame
and 'data
. The first of these ensures that a Value
can only be
used while it’s rooted in a GcFrame
, the second accounts for data borrowed from
Rust. The only way to borrow data from Rust is to create an Julia array that borrows its
contents by calling Value::borrow_array
, if a Julia function is called with such an array as
an argument the result will inherit the second lifetime of the borrowed data to ensure that
such a Value
can onl be used while the borrow is active.
Implementations
impl<'frame, 'data> Value<'frame, 'data>
[src]
impl<'frame, 'data> Value<'frame, 'data>
[src]Create new Value
s
Several methods are available to create new values. The simplest of these is Value::new
,
which can be used to convert relatively simple data from Rust to Julia. Data that can be
converted this way must implement IntoJulia
, which is the case for some simple types like
primitive number types and strings. This trait is also automatically derived by
JlrsReflect.jl
for types that are trivially guaranteed to be bits-types: the type must have
no type parameters, no unions, and all fields must have bits-types themselves.
Data that isn’t supported by Value::new
can still be created from Rust in many cases. New
arrays can be created with Value::new_array
, if you want to have the array be backed by
data from Rust Value::borrow_array
and Value::move_array
can be used. It’s currently
only possible to create new arrays if the element type implements IntoJulia
and
JuliaType
. Methods to create new UnionAll
s and Union
s are also available.
Finally, it’s possible to instantiate arbitrary concrete types with Value::instantiate
,
the type parameters of types that have them can be set with Value::apply_type
. These
methods don’t support creating new arrays.
pub fn new<'scope, V, S, F>(scope: S, value: V) -> JlrsResult<S::Value> where
V: IntoJulia,
S: Scope<'scope, 'frame, 'static, F>,
F: Frame<'frame>,
[src]
V: IntoJulia,
S: Scope<'scope, 'frame, 'static, F>,
F: Frame<'frame>,
Create a new Julia value, any type that implements IntoJulia
can be converted using
this function. The value will be protected from garbage collection inside the frame used
to create it. One free slot on the GC stack is required for this function to succeed,
returns an error if no slot is available.
pub fn instantiate<'scope, 'value, 'borrow, V, S, F>(
scope: S,
ty: DataType<'_>,
values: V
) -> JlrsResult<S::Value> where
V: AsMut<[Value<'value, 'borrow>]>,
S: Scope<'scope, 'frame, 'borrow, F>,
F: Frame<'frame>,
[src]
scope: S,
ty: DataType<'_>,
values: V
) -> JlrsResult<S::Value> where
V: AsMut<[Value<'value, 'borrow>]>,
S: Scope<'scope, 'frame, 'borrow, F>,
F: Frame<'frame>,
Create a new instance of a value with DataType
ty
, using values
to set the fields.
This is essentially a more powerful version of Value::new
and can instantiate
arbitrary concrete DataType
s, at the cost that each of its fields must have already been
allocated as a Value
. This functions returns an error if the given DataType
is not
concrete. One free slot on the GC stack is required for this function to succeed, returns
an error if no slot is available.
pub fn new_array<'scope, T, D, S, F>(
scope: S,
dimensions: D
) -> JlrsResult<S::Value> where
T: IntoJulia + JuliaType,
D: Into<Dimensions>,
S: Scope<'scope, 'frame, 'static, F>,
F: Frame<'frame>,
[src]
scope: S,
dimensions: D
) -> JlrsResult<S::Value> where
T: IntoJulia + JuliaType,
D: Into<Dimensions>,
S: Scope<'scope, 'frame, 'static, F>,
F: Frame<'frame>,
Allocates a new n-dimensional array in Julia.
Creating an an array with 1, 2 or 3 dimensions requires one slot on the GC stack. If you create an array with more dimensions an extra frame is created with a single slot, temporarily taking 3 additional slots.
This function returns an error if there are not enough slots available.
pub fn borrow_array<'scope, T, D, V, S, F>(
scope: S,
data: V,
dimensions: D
) -> JlrsResult<S::Value> where
T: IntoJulia + JuliaType,
D: Into<Dimensions>,
V: AsMut<[T]> + 'data,
S: Scope<'scope, 'frame, 'data, F>,
F: Frame<'frame>,
[src]
scope: S,
data: V,
dimensions: D
) -> JlrsResult<S::Value> where
T: IntoJulia + JuliaType,
D: Into<Dimensions>,
V: AsMut<[T]> + 'data,
S: Scope<'scope, 'frame, 'data, F>,
F: Frame<'frame>,
Borrows an n-dimensional array from Rust for use in Julia.
Borrowing an array with one dimension requires one slot on the GC stack. If you borrow an array with more dimensions, an extra frame is created with a single slot slot, temporarily taking 3 additional slots.
This function returns an error if there are not enough slots available.
pub fn move_array<'scope, T, D, S, F>(
scope: S,
data: Vec<T>,
dimensions: D
) -> JlrsResult<S::Value> where
T: IntoJulia + JuliaType,
D: Into<Dimensions>,
S: Scope<'scope, 'frame, 'static, F>,
F: Frame<'frame>,
[src]
scope: S,
data: Vec<T>,
dimensions: D
) -> JlrsResult<S::Value> where
T: IntoJulia + JuliaType,
D: Into<Dimensions>,
S: Scope<'scope, 'frame, 'static, F>,
F: Frame<'frame>,
Moves an n-dimensional array from Rust to Julia.
Moving an array with one dimension requires one slot on the GC stack. If you move an array with more dimensions, an extra frame is created with a single slot slot, temporarily taking 3 additional slots.
This function returns an error if there are not enough slots available.
pub fn new_union<'scope, S, F>(
scope: S,
types: &mut [Value<'_, 'data>]
) -> JlrsResult<S::Value> where
S: Scope<'scope, 'frame, 'data, F>,
F: Frame<'frame>,
[src]
scope: S,
types: &mut [Value<'_, 'data>]
) -> JlrsResult<S::Value> where
S: Scope<'scope, 'frame, 'data, F>,
F: Frame<'frame>,
Returns the union of all types in types
. For each of these types, Value::is_kind
must return true
. TNote that the result is not necessarily a Union
, for example the
union of a single DataType
is that type, not a Union
with a single variant. One free
slot on the GC stack is required for this function to succeed, returns an error if no slot is available.
pub fn new_unionall<'scope, S, F>(
scope: S,
tvar: TypeVar<'_>,
body: Value<'_, 'data>
) -> JlrsResult<S::Value> where
S: Scope<'scope, 'frame, 'data, F>,
F: Frame<'frame>,
[src]
scope: S,
tvar: TypeVar<'_>,
body: Value<'_, 'data>
) -> JlrsResult<S::Value> where
S: Scope<'scope, 'frame, 'data, F>,
F: Frame<'frame>,
Create a new UnionAll
. One free slot on the GC stack is required for this function to
succeed, returns an error if no slot is available.
pub fn new_named_tuple<'scope, 'value, S, F, N, T, V>(
scope: S,
field_names: N,
values: V
) -> JlrsResult<S::Value> where
S: Scope<'scope, 'frame, 'data, F>,
F: Frame<'frame>,
N: AsMut<[T]>,
T: TemporarySymbol,
V: AsMut<[Value<'value, 'data>]>,
[src]
scope: S,
field_names: N,
values: V
) -> JlrsResult<S::Value> where
S: Scope<'scope, 'frame, 'data, F>,
F: Frame<'frame>,
N: AsMut<[T]>,
T: TemporarySymbol,
V: AsMut<[Value<'value, 'data>]>,
Create a new named tuple, you can use the named_tuple
macro instead of this method.
pub fn new_typevar<'scope, S, F, N>(
scope: S,
name: N,
lower_bound: Option<Value<'_, '_>>,
upper_bound: Option<Value<'_, '_>>
) -> JlrsResult<S::Value> where
F: Frame<'frame>,
S: Scope<'scope, 'frame, 'data, F>,
N: TemporarySymbol,
[src]
scope: S,
name: N,
lower_bound: Option<Value<'_, '_>>,
upper_bound: Option<Value<'_, '_>>
) -> JlrsResult<S::Value> where
F: Frame<'frame>,
S: Scope<'scope, 'frame, 'data, F>,
N: TemporarySymbol,
Create a new TypeVar
, the optional lower and upper bounds must be subtypes of Type
,
their default values are Union{}
and Any
respectively.
pub fn apply_type<'scope, 'fr, 'value, 'borrow, S, F, V>(
self,
scope: S,
types: V
) -> JlrsResult<S::Value> where
S: Scope<'scope, 'fr, 'borrow, F>,
F: Frame<'fr>,
V: AsMut<[Value<'value, 'borrow>]>,
[src]
self,
scope: S,
types: V
) -> JlrsResult<S::Value> where
S: Scope<'scope, 'fr, 'borrow, F>,
F: Frame<'fr>,
V: AsMut<[Value<'value, 'borrow>]>,
Apply the given types to self
.
If self
is the DataType
anytuple_type
, calling this function will return a new
tuple type with the given types as its field types. If it is the DataType
uniontype_type
, calling this function is equivalent to calling Value::new_union
. If
the value is a UnionAll
, the given types will be applied and the resulting type is
returned.
If the types cannot be applied to self
your program will abort.
One free slot on the GC stack is required for this function to succeed, returns an error if no slot is available.
impl<'frame, 'data> Value<'frame, 'data>
[src]
impl<'frame, 'data> Value<'frame, 'data>
[src]Type information
Every non-null value is guaranteed to have a DataType
. This contains all of the value’s type
information.
impl<'frame, 'data> Value<'frame, 'data>
[src]
impl<'frame, 'data> Value<'frame, 'data>
[src]Type checking
In many cases you want to know about certain properties of a value’s type. The most
important method you will find here is Value::is
, which can be used in combination
with anything that implements JuliaTypecheck
.
pub fn is_nothing(self) -> bool
[src]
Returns true if the value is nothing
. Note that the Julia C API often returns a null
pointer instead of nothing
, this method return false if the given value is a null
pointer.
pub fn is_null(self) -> bool
[src]
Returns true if the value is a null pointer.
pub fn is<T: JuliaTypecheck>(self) -> bool
[src]
Performs the given type check. For types that represent Julia data, this check comes down to checking if the data has that type and can be cast to it. This works for primitive types, for example:
julia.scope(|_global, frame| { let i = Value::new(frame, 2u64)?; assert!(i.is::<u64>()); Ok(()) }).unwrap();
“Special” types in Julia that are defined in C, like Array
, Module
and
DataType
, are also supported:
julia.scope(|_global, frame| { let arr = Value::new_array::<f64, _, _, _>(&mut *frame, (3, 3))?; assert!(arr.is::<Array>()); Ok(()) }).unwrap();
If you derive JuliaStruct
for some type, that type will be supported by this method. A
full list of supported checks can be found here.
pub fn is_array_of<T: ValidLayout>(self) -> bool
[src]
Returns true if the value is an array with elements of type T
.
pub fn subtype(self, sup: Value<'_, '_>) -> bool
[src]
Returns true if self
is a subtype of sup
.
pub fn is_kind(self) -> bool
[src]
Returns true if self
is the type of a DataType
, UnionAll
, Union
, or Union{}
(the
bottom type).
pub fn is_type(self) -> bool
[src]
Returns true if the value is a type, ie a DataType
, UnionAll
, Union
, or Union{}
(the bottom type).
pub fn isa(self, ty: Value<'_, '_>) -> bool
[src]
Returns true if self
is of type ty
.
impl<'frame, 'data> Value<'frame, 'data>
[src]
impl<'frame, 'data> Value<'frame, 'data>
[src]Lifetime management
Values have two lifetimes, 'frame
and 'data
. The first ensures that a value can only be
used while it’s rooted in a frame, the second ensures that values that (might) borrow array
data from Rust are also restricted by the lifetime of that borrow. This second restriction
can be relaxed with Value::assume_owned
.
pub unsafe fn assume_owned(self) -> Value<'frame, 'static>
[src]
If you call a function with one or more borrowed arrays as arguments, its result can only
be used when all the borrows are active. If this result doesn’t reference any borrowed
data this function can be used to relax its second lifetime to 'static
.
Safety: The value must not contain a reference any borrowed data.
pub fn reroot<'scope, 'f, S, F>(self, scope: S) -> JlrsResult<S::Value> where
F: Frame<'f>,
S: Scope<'scope, 'f, 'data, F>,
[src]
F: Frame<'f>,
S: Scope<'scope, 'f, 'data, F>,
Root the value again in some scope
.
impl<'frame, 'data> Value<'frame, 'data>
[src]
impl<'frame, 'data> Value<'frame, 'data>
[src]Casting to Rust
A Value
is equivalent to the Any
type in Julia. In order to convert it to a more usable
type it must be cast. Casting can convert a value to its underlying type. In the
case of builtin pointer types like Array
and DataType
, casting is a pointer-cast.
After casting, they can be turned back into a Value
by calling the as_value
method. For
primitive types and structs that derive JuliaStruct
, the pointer is dereferenced.
pub fn cast<T: Cast<'frame, 'data>>(
self
) -> JlrsResult<<T as Cast<'frame, 'data>>::Output>
[src]
self
) -> JlrsResult<<T as Cast<'frame, 'data>>::Output>
Cast the contents of this value into a compatible Rust type. Any type which implements
Cast
can be used as a target, by default this includes primitive types like u8
, f32
and bool
, and builtin types like Array
, JuliaString
and Symbol
. You can
implement this trait for custom types by deriving JuliaStruct
.
pub unsafe fn cast_unchecked<T: Cast<'frame, 'data>>(
self
) -> <T as Cast<'frame, 'data>>::Output
[src]
self
) -> <T as Cast<'frame, 'data>>::Output
Cast the contents of this value into a compatible Rust type without checking if the layout is valid.
Safety:
You must guarantee self.is::<T>()
would have returned true
.
impl<'frame, 'data> Value<'frame, 'data>
[src]
impl<'frame, 'data> Value<'frame, 'data>
[src]Fields
Values have fields. For example, if the value contains an instance of this struct:
struct Example
fielda
fieldb::UInt32
end
it will have two fields, fielda
and fieldb
. The first field is stored as a Value
, the
second field is stored inline as a u32
. If the second field is converted to a Value
with
one of the field access methods below, this new value must be rooted. The first field can be
accessed without allocating.
If you wish to avoid this allocation when accessing fields, it’s possible to generate bindings
for a struct like this with JlrsReflect.jl
, which allows them to be converted to a compatible
Rust struct with Value::cast
.
pub fn field_names(self) -> &'frame [Symbol<'frame>]
[src]
Returns the field names of this value as a slice of Symbol
s. These symbols can be used
to access their fields with Value::get_field
.
pub fn n_fields(self) -> usize
[src]
Returns the number of fields the underlying Julia value has. These fields can be accessed
with Value::get_nth_field
.
pub fn get_nth_field<'scope, 'fr, S, F>(
self,
scope: S,
idx: usize
) -> JlrsResult<S::Value> where
S: Scope<'scope, 'fr, 'data, F>,
F: Frame<'fr>,
[src]
self,
scope: S,
idx: usize
) -> JlrsResult<S::Value> where
S: Scope<'scope, 'fr, 'data, F>,
F: Frame<'fr>,
Returns the field at index idx
if it exists. If it does not exist
JlrsError::OutOfBounds
is returned. This function assumes the field must be protected
from garbage collection, so calling this function will take a single slot on the GC stack.
If there is no slot available JlrsError::AllocError
is returned.
pub unsafe fn get_nth_field_noalloc(
self,
idx: usize
) -> JlrsResult<Value<'frame, 'data>>
[src]
self,
idx: usize
) -> JlrsResult<Value<'frame, 'data>>
Returns the field at index idx
if it exists and no allocation is required to return it.
Allocation is not required if the field is a pointer to another value.
If the field does not exist JlrsError::NoSuchField
is returned. If allocating is
required to return the field, JlrsError::NotAPointerField
is returned.
This function is unsafe because the value returned as a result will only be valid as long as the field is not changed.
pub fn get_field<'scope, 'fr, N, S, F>(
self,
scope: S,
field_name: N
) -> JlrsResult<S::Value> where
N: TemporarySymbol,
S: Scope<'scope, 'fr, 'data, F>,
F: Frame<'fr>,
[src]
self,
scope: S,
field_name: N
) -> JlrsResult<S::Value> where
N: TemporarySymbol,
S: Scope<'scope, 'fr, 'data, F>,
F: Frame<'fr>,
Returns the field with the name field_name
if it exists. If it does not exist
JlrsError::NoSuchField
is returned. This function assumes the field must be protected
from garbage collection, so calling this function will take a single slot on the GC stack.
If there is no slot available JlrsError::AllocError
is returned.
pub unsafe fn get_field_noalloc<N>(
self,
field_name: N
) -> JlrsResult<Value<'frame, 'data>> where
N: TemporarySymbol,
[src]
self,
field_name: N
) -> JlrsResult<Value<'frame, 'data>> where
N: TemporarySymbol,
Returns the field with the name field_name
if it exists and no allocation is required
to return it. Allocation is not required if the field is a pointer to another value.
If the field does not exist JlrsError::NoSuchField
is returned. If allocating is
required to return the field, JlrsError::NotAPointerField
is returned.
This function is unsafe because the value returned as a result will only be valid as long as the field is not changed.
pub unsafe fn set_nth_field(
self,
idx: usize,
value: Value<'_, '_>
) -> JlrsResult<()>
[src]
self,
idx: usize,
value: Value<'_, '_>
) -> JlrsResult<()>
Set the value of the field at idx
. Returns an error if this value is immutable or if the
type of value
is not a subtype of the field type. This is unsafe because the previous
value of this field can become unrooted if you’re directly using it from Rust.
impl<'fr, 'da> Value<'fr, 'da>
[src]
impl<'fr, 'da> Value<'fr, 'da>
[src]Call Julia.
Several methods are available to call Julia. Raw commands can be executed with eval_string
and eval_cstring
, but these can’t take any arguments. In order to call functions that take
arguments, you must use one of the call
methods which will call that value as a function
with some number of arguments, these methods can be found in the Call
trait. In order to
call functions with keyword arguments you must call Value::with_keywords
to provide the
keyword arguments as a NamedTuple
, and then use one of the methods from the Call
trait.
When the async runtime is used, the method Value::call_async
is available which calls
that function on another thread in Julia.
pub fn with_keywords<'kws>(
self,
keywords: Value<'kws, 'da>
) -> WithKeywords<'fr, 'kws, 'da>
[src]
self,
keywords: Value<'kws, 'da>
) -> WithKeywords<'fr, 'kws, 'da>
Provide keywords to this function.
Functions that can take keyword arguments can be called in two major ways, either with or
without keyword arguments. The Call
trait takes care of the frst case, this one
takes care of the second.
Example:
julia.scope(|global, frame| { let a_value = Value::new(&mut *frame, 1isize)?; let b_value = Value::new(&mut *frame, 10isize)?; // `funcwithkw` takes a single positional argument of type `Int`, one keyword // argument named `b` of the same type, and returns `a` + `b`. let func = Module::main(global) .submodule("JlrsTests")? .function("funcwithkw")?; let kw = named_tuple!(&mut *frame, "b" => b_value)?; let res = func.with_keywords(kw) .call1(&mut *frame, a_value)? .unwrap() .cast::<isize>()?; assert_eq!(res, 11); Ok(()) }).unwrap();
pub fn eval_string<'frame, F, S>(
frame: &mut F,
cmd: S
) -> JlrsResult<JuliaResult<'frame, 'static>> where
F: Frame<'frame>,
S: AsRef<str>,
[src]
frame: &mut F,
cmd: S
) -> JlrsResult<JuliaResult<'frame, 'static>> where
F: Frame<'frame>,
S: AsRef<str>,
Execute a Julia command cmd
, for example
Value::eval_string(frame, "sqrt(2)")
.
pub fn eval_cstring<'frame, F, S>(
frame: &mut F,
cmd: S
) -> JlrsResult<JuliaResult<'frame, 'static>> where
F: Frame<'frame>,
S: AsRef<CStr>,
[src]
frame: &mut F,
cmd: S
) -> JlrsResult<JuliaResult<'frame, 'static>> where
F: Frame<'frame>,
S: AsRef<CStr>,
Execute a Julia command cmd
. This is equivalent to Value::eval_string
, but uses a
null-terminated string.
pub unsafe fn call0_unprotected<'base>(
self,
_: Global<'base>
) -> JuliaResult<'base, 'static>
[src]
self,
_: Global<'base>
) -> JuliaResult<'base, 'static>
Call this value as a function that takes zero arguments and don’t protect the result from
garbage collection. This is safe if you won’t use the result or if you can guarantee it’s
a global value in Julia, e.g. nothing
or a Module
.
pub unsafe fn call1_unprotected<'base, 'data>(
self,
_: Global<'base>,
arg: Value<'_, 'data>
) -> JuliaResult<'base, 'data>
[src]
self,
_: Global<'base>,
arg: Value<'_, 'data>
) -> JuliaResult<'base, 'data>
Call this value as a function that takes one argument and don’t protect the result from
garbage collection. This is safe if you won’t use the result or if you can guarantee it’s
a global value in Julia, e.g. nothing
or a Module
.
pub unsafe fn call2_unprotected<'base, 'data>(
self,
_: Global<'base>,
arg0: Value<'_, 'data>,
arg1: Value<'_, 'data>
) -> JuliaResult<'base, 'data>
[src]
self,
_: Global<'base>,
arg0: Value<'_, 'data>,
arg1: Value<'_, 'data>
) -> JuliaResult<'base, 'data>
Call this value as a function that takes two arguments and don’t protect the result from
garbage collection. This is safe if you won’t use the result or if you can guarantee it’s
a global value in Julia, e.g. nothing
or a Module
.
pub unsafe fn call3_unprotected<'base, 'borrow>(
self,
_: Global<'base>,
arg0: Value<'_, 'borrow>,
arg1: Value<'_, 'borrow>,
arg2: Value<'_, 'borrow>
) -> JuliaResult<'base, 'borrow>
[src]
self,
_: Global<'base>,
arg0: Value<'_, 'borrow>,
arg1: Value<'_, 'borrow>,
arg2: Value<'_, 'borrow>
) -> JuliaResult<'base, 'borrow>
Call this value as a function that takes three arguments and don’t protect the result from
garbage collection. This is safe if you won’t use the result or if you can guarantee it’s
a global value in Julia, e.g. nothing
or a Module
.
pub unsafe fn call_unprotected<'base, 'value, 'data, V, F>(
self,
_: Global<'base>,
args: V
) -> JuliaResult<'base, 'data> where
V: AsMut<[Value<'value, 'data>]>,
[src]
self,
_: Global<'base>,
args: V
) -> JuliaResult<'base, 'data> where
V: AsMut<[Value<'value, 'data>]>,
Call this value as a function that takes several arguments and don’t protect the result
from garbage collection. This is safe if you won’t use the result or if you can guarantee
it’s a global value in Julia, e.g. nothing
or a Module
.
pub unsafe fn call_keywords_unprotected<'base, 'value, 'data, V, F>(
self,
_: Global<'base>,
args: V
) -> JuliaResult<'base, 'data> where
V: AsMut<[Value<'value, 'data>]>,
[src]
self,
_: Global<'base>,
args: V
) -> JuliaResult<'base, 'data> where
V: AsMut<[Value<'value, 'data>]>,
Call this value as a function that takes keyword arguments, any number of positional
arguments and don’t protect the result from garbage collection. This is safe if you won’t
use the result or if you can guarantee it’s a global value in Julia, e.g. nothing
or a
Module
.
pub async fn call_async<'frame, 'value, 'data, V>(
self,
frame: &mut AsyncGcFrame<'frame>,
args: V
) -> JlrsResult<JuliaResult<'frame, 'data>> where
V: AsMut<[Value<'value, 'data>]>,
[src]
self,
frame: &mut AsyncGcFrame<'frame>,
args: V
) -> JlrsResult<JuliaResult<'frame, 'data>> where
V: AsMut<[Value<'value, 'data>]>,
Call this value as a function that takes several arguments and execute it on another
thread in Julia created with Base.@spawn
, this takes two slots on the GC stack. Returns
the result of this function call if no exception is thrown, the exception if one is, or an
error if no space is left on the stack.
This function can only be called with an AsyncGcFrame
, while you’re waiting for this
function to complete, other tasks are able to progress.
pub fn tracing_call<'frame, F>(
self,
frame: &mut F
) -> JlrsResult<JuliaResult<'frame, 'da>> where
F: Frame<'frame>,
[src]
self,
frame: &mut F
) -> JlrsResult<JuliaResult<'frame, 'da>> where
F: Frame<'frame>,
Returns an anonymous function that wraps this value in a try-catch block. Calling this anonymous function with some arguments will call the value as a function with those arguments and return its result, or catch the exception, print the stackstrace, and rethrow that exception. This takes one slot on the GC stack.
pub fn attach_stacktrace<'frame, F>(
self,
frame: &mut F
) -> JlrsResult<JuliaResult<'frame, 'da>> where
F: Frame<'frame>,
[src]
self,
frame: &mut F
) -> JlrsResult<JuliaResult<'frame, 'da>> where
F: Frame<'frame>,
Returns an anonymous function that wraps this value in a try-catch block. Calling this
anonymous function with some arguments will call the value as a function with those
arguments and return its result, or catch the exception and throw a new one with two
fields, exc
and stacktrace
, containing the original exception and the stacktrace
respectively. This takes one slot on the GC stack.
impl Value<'_, '_>
[src]
impl Value<'_, '_>
[src]pub unsafe fn add_finalizer(self, f: Value<'_, '_>)
[src]
Add a finalizer f
to this value. The finalizer must be a Julia function, it will be
called when this value is about to be freed by the garbage collector.
pub unsafe fn finalize(self)
[src]
Call all finalizers.
impl<'base> Value<'base, 'static>
[src]
impl<'base> Value<'base, 'static>
[src]pub fn bottom_type(_: Global<'base>) -> Self
[src]
Core.Union{}
.
pub fn stackovf_exception(_: Global<'base>) -> Self
[src]
Core.StackOverflowError
.
pub fn memory_exception(_: Global<'base>) -> Self
[src]
Core.OutOfMemoryError
.
pub fn readonlymemory_exception(_: Global<'base>) -> Self
[src]
Core.ReadOnlyMemoryError
.
pub fn diverror_exception(_: Global<'base>) -> Self
[src]
Core.DivideError
.
pub fn undefref_exception(_: Global<'base>) -> Self
[src]
Core.UndefRefError
.
pub fn interrupt_exception(_: Global<'base>) -> Self
[src]
Core.InterruptException
.
pub fn an_empty_vec_any(_: Global<'base>) -> Self
[src]
An empty `Core.Array{Any, 1}.
pub fn an_empty_string(_: Global<'base>) -> Self
[src]
An empty immutable String, “”.
pub fn array_uint8_type(_: Global<'base>) -> Self
[src]
Core.Array{UInt8, 1}
pub fn array_any_type(_: Global<'base>) -> Self
[src]
Core.Array{Any, 1}
pub fn array_symbol_type(_: Global<'base>) -> Self
[src]
Core.Array{Symbol, 1}
pub fn array_int32_type(_: Global<'base>) -> Self
[src]
Core.Array{Int32, 1}
pub fn emptytuple(_: Global<'base>) -> Self
[src]
The empty tuple, ()
.
pub fn true_v(_: Global<'base>) -> Self
[src]
The instance of true
.
pub fn false_v(_: Global<'base>) -> Self
[src]
The instance of false
.
pub fn nothing(_: Global<'base>) -> Self
[src]
The instance of Core.Nothing
, nothing
.
Trait Implementations
impl<'scope, 'frame, 'data, 'inner> AsUnrooted<'scope, 'frame, 'data, 'inner> for Value<'frame, 'data>
[src]
impl<'scope, 'frame, 'data, 'inner> AsUnrooted<'scope, 'frame, 'data, 'inner> for Value<'frame, 'data>
[src]type Unrooted = UnrootedValue<'scope, 'data, 'inner>
fn as_unrooted<F: Frame<'frame>>(
self,
_output: OutputScope<'scope, 'frame, 'inner, F>
) -> Self::Unrooted
[src]
self,
_output: OutputScope<'scope, 'frame, 'inner, F>
) -> Self::Unrooted
impl<'scope, 'frame, 'data> Call<'scope, 'frame, 'data> for Value<'_, 'data>
[src]
impl<'scope, 'frame, 'data> Call<'scope, 'frame, 'data> for Value<'_, 'data>
[src]fn call0<S, F>(self, scope: S) -> JlrsResult<S::JuliaResult> where
S: Scope<'scope, 'frame, 'data, F>,
F: Frame<'frame>,
[src]
S: Scope<'scope, 'frame, 'data, F>,
F: Frame<'frame>,
fn call1<S, F>(
self,
scope: S,
arg0: Value<'_, 'data>
) -> JlrsResult<S::JuliaResult> where
S: Scope<'scope, 'frame, 'data, F>,
F: Frame<'frame>,
[src]
self,
scope: S,
arg0: Value<'_, 'data>
) -> JlrsResult<S::JuliaResult> where
S: Scope<'scope, 'frame, 'data, F>,
F: Frame<'frame>,
fn call2<S, F>(
self,
scope: S,
arg0: Value<'_, 'data>,
arg1: Value<'_, 'data>
) -> JlrsResult<S::JuliaResult> where
S: Scope<'scope, 'frame, 'data, F>,
F: Frame<'frame>,
[src]
self,
scope: S,
arg0: Value<'_, 'data>,
arg1: Value<'_, 'data>
) -> JlrsResult<S::JuliaResult> where
S: Scope<'scope, 'frame, 'data, F>,
F: Frame<'frame>,
fn call3<S, F>(
self,
scope: S,
arg0: Value<'_, 'data>,
arg1: Value<'_, 'data>,
arg2: Value<'_, 'data>
) -> JlrsResult<S::JuliaResult> where
S: Scope<'scope, 'frame, 'data, F>,
F: Frame<'frame>,
[src]
self,
scope: S,
arg0: Value<'_, 'data>,
arg1: Value<'_, 'data>,
arg2: Value<'_, 'data>
) -> JlrsResult<S::JuliaResult> where
S: Scope<'scope, 'frame, 'data, F>,
F: Frame<'frame>,
fn call<'value, V, S, F>(self, scope: S, args: V) -> JlrsResult<S::JuliaResult> where
V: AsMut<[Value<'value, 'data>]>,
S: Scope<'scope, 'frame, 'data, F>,
F: Frame<'frame>,
[src]
V: AsMut<[Value<'value, 'data>]>,
S: Scope<'scope, 'frame, 'data, F>,
F: Frame<'frame>,
impl<'frame, 'data, T: Copy + ValidLayout> Into<Value<'frame, 'data>> for TypedArray<'frame, 'data, T>
[src]
impl<'frame, 'data, T: Copy + ValidLayout> Into<Value<'frame, 'data>> for TypedArray<'frame, 'data, T>
[src]impl<'frame> Into<Value<'frame, 'static>> for CodeInstance<'frame>
[src]
impl<'frame> Into<Value<'frame, 'static>> for CodeInstance<'frame>
[src]impl<'frame> Into<Value<'frame, 'static>> for TypeMapEntry<'frame>
[src]
impl<'frame> Into<Value<'frame, 'static>> for TypeMapEntry<'frame>
[src]impl<'frame> Into<Value<'frame, 'static>> for TypeMapLevel<'frame>
[src]
impl<'frame> Into<Value<'frame, 'static>> for TypeMapLevel<'frame>
[src]impl<'frame> Into<Value<'frame, 'static>> for MethodInstance<'frame>
[src]
impl<'frame> Into<Value<'frame, 'static>> for MethodInstance<'frame>
[src]impl<'frame> Into<Value<'frame, 'static>> for MethodTable<'frame>
[src]
impl<'frame> Into<Value<'frame, 'static>> for MethodTable<'frame>
[src]impl<'frame> Into<Value<'frame, 'static>> for SimpleVector<'frame>
[src]
impl<'frame> Into<Value<'frame, 'static>> for SimpleVector<'frame>
[src]impl<'frame> Into<Value<'frame, 'static>> for JuliaString<'frame>
[src]
impl<'frame> Into<Value<'frame, 'static>> for JuliaString<'frame>
[src]impl<'frame, 'data> JuliaType for Value<'frame, 'data>
[src]
impl<'frame, 'data> JuliaType for Value<'frame, 'data>
[src]unsafe fn julia_type() -> *mut jl_datatype_t
[src]
impl<'frame, 'data> ValidLayout for Value<'frame, 'data>
[src]
impl<'frame, 'data> ValidLayout for Value<'frame, 'data>
[src]unsafe fn valid_layout(v: Value<'_, '_>) -> bool
[src]
Auto Trait Implementations
impl<'frame, 'data> RefUnwindSafe for Value<'frame, 'data>
impl<'frame, 'data> RefUnwindSafe for Value<'frame, 'data>
impl<'frame, 'data> UnwindSafe for Value<'frame, 'data>
impl<'frame, 'data> UnwindSafe for Value<'frame, 'data>