Struct jlrs::data::managed::value::Value

source ·
#[repr(transparent)]
pub struct Value<'scope, 'data>(_, _, _);
Expand description

Arbitrary Julia data.

A Value is essentially a non-null pointer to some data owned by the Julia garbage collector with two lifetimes: 'scope and 'data. The first of these ensures that a Value can only be used while it’s rooted, 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 Array::from_slice; 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 only be used while the borrow is active.

See the [module-level documentation] for more information.

Implementations§

source§

impl Value<'_, '_>

Create new Values

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 types like the primitive number types. 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 be immutable bits-types themselves.

source

pub fn new<'target, V, Tgt>( target: Tgt, value: V ) -> ValueData<'target, 'static, Tgt>where V: IntoJulia, Tgt: Target<'target>,

Create a new Julia value, any type that implements IntoJulia can be converted using this function.

source

pub fn new_bits<'target, T, Tgt>( target: Tgt, layout: T ) -> ValueData<'target, 'static, Tgt>where T: ConstructType + ValidLayout + IsBits, Tgt: Target<'target>,

Create a new Julia value, any type that implements IsBits can be converted using this function.

source

pub fn new_bits_from_layout<'target, T, Tgt>( target: Tgt, layout: T::Layout ) -> JlrsResult<ValueData<'target, 'static, Tgt>>where T: HasLayout<'target, 'static>, T::Layout: IsBits, Tgt: Target<'target>,

Create a new Julia value using T to construct the type. The layout must implement IsBits.

source

pub fn new_bits_with_type<'target, T, L, Tgt>( target: Tgt, layout: L ) -> JlrsResult<ValueData<'target, 'static, Tgt>>where T: ConstructType, L: IsBits + ValidLayout, Tgt: Target<'target>,

Create a new Julia value using T to construct the type and an arbitrary layout L.

If the layout is not valid for T TypeError::InvalidLayout is returned.

source

pub unsafe fn try_new_with<'target, Ty, L, Tgt>( target: Tgt, layout: L ) -> JlrsResult<ValueData<'target, 'static, Tgt>>where Ty: ConstructType, L: ValidLayout, Tgt: Target<'target>,

Create a new Value from the provided layout and type constructor.

This is a more powerful version of Value::new. While that method is limited to types that implement IntoJulia, this method can create instances of any constructible type by providing a layout which is compatible with that type.

This method returns an error if L is not a valid layout for V.

Safety:

If the layout contains references to Julia data, those fields must either be None or point to valid data.

source

pub fn new_named_tuple<'target, 'value, 'data, Tgt, const N: usize>( target: Tgt, pairs: &[(Symbol<'value>, Value<'value, 'data>); N] ) -> ValueData<'target, 'data, Tgt>where Tgt: Target<'target>,

Create a new named tuple, you should use the named_tuple macro rather than this method.

source

pub fn apply_type<'target, 'value, 'data, V, T>( self, target: T, types: V ) -> ValueResult<'target, 'data, T>where T: Target<'target>, V: AsRef<[Value<'value, 'data>]>,

Apply the given types to self.

If self is the DataType anytuple_type, calling this method will return a new tuple type with the given types as its field types. If it is the DataType uniontype_type, calling this method is equivalent to calling Union::new. If the value is a UnionAll, the given types will be applied and the resulting type is returned.

If the types can’t be applied to self this methods catches and returns the exception.

source

pub unsafe fn apply_type_unchecked<'target, 'value, 'data, T, V>( self, target: T, types: V ) -> ValueData<'target, 'data, T>where T: Target<'target>, V: AsRef<[Value<'value, 'data>]>,

Apply the given types to self.

If self is the DataType anytuple_type, calling this method will return a new tuple type with the given types as its field types. If it is the DataType uniontype_type, calling this method is equivalent to calling Union::new. If the value is a UnionAll, the given types will be applied and the resulting type is returned.

If an exception is thrown it isn’t caught

Safety: an exception must not be thrown if this method is called from a ccalled function.

source§

impl<'scope, 'data> Value<'scope, 'data>

Type information

Every value is guaranteed to have a DataType. This contains all of the value’s type information.

source

pub fn datatype(self) -> DataType<'scope>

Returns the DataType of this value.

source

pub fn datatype_name(self) -> JlrsResult<&'scope str>

Returns the name of this value’s DataType as a string slice.

source§

impl Value<'_, '_>

Type checking

Many properties of Julia types can be checked, including whether instances of the type are mutable, if the value is an array, and so on. The method Value::is can be used to perform these checks. All these checks implement the Typecheck trait. If the type that implements this trait also implements ValidLayout, the typecheck indicates whether or not the value can be cast to or unboxed as that type.

source

pub fn is<T: Typecheck>(self) -> bool

Performs the given typecheck:

julia
    .scope(|mut frame| {
        let i = Value::new(&mut frame, 2u64);
        assert!(i.is::<u64>());
        Ok(())
    })
    .unwrap();

A full list of supported checks can be found here.

source

pub fn is_array_of<T: ValidField>(self) -> bool

Returns true if the value is an array with elements of type T.

source

pub fn subtype(self, sup: Value<'_, '_>) -> bool

Returns true if self is a subtype of sup.

source

pub fn is_kind(self) -> bool

Returns true if self is the type of a DataType, UnionAll, Union, or Union{} (the bottom type).

source

pub fn is_type(self) -> bool

Returns true if the value is a type, ie a DataType, UnionAll, Union, or Union{} (the bottom type).

source

pub fn isa(self, ty: Value<'_, '_>) -> bool

Returns true if self is of type ty.

source§

impl<'scope, 'data> Value<'scope, 'data>

These methods let you track a Value, while it’s tracked it’s internal pointer is dereferenced and you can access its contents directly.

Tracking works with a ledger that’s shared between all active instances of jlrs. This ledger contains a list of all active borrows, which lets it be used to prevent mutable aliasing. Unfortunately, this system isn’t perfect, it’s unaware of how this data is used in Julia. It’s your responsibility that you only try to access data which isn’t being used by some task running in the background. The raw ledger API is available in JlrsCore.Ledger, you can prevent mutable access to data by tracking from Julia by calling these functions. If you do so, you should use a finalizer to ensure the borrow is removed from the ledger when the data is finalized.

source

pub fn track_shared<'borrow, T: ValidLayout>( &'borrow self ) -> JlrsResult<Tracked<'borrow, 'scope, 'data, T>>

Track self immutably.

When this method is called on some Value, it’s checked if the layout of T matches that of the data and if the data is already mutably borrowed from Rust. If it’s not, the data is derefenced and returned as a Tracked which provides direct access to the reference.

If the data is immutable the borrow isn’t tracked by the ledger because it can’t be mutably borrowed.

source

pub unsafe fn track_exclusive<'borrow, T: ValidLayout>( &'borrow mut self ) -> JlrsResult<TrackedMut<'borrow, 'scope, 'data, T>>

Track self exclusively.

When this method is called on some Value, it’s checked if the layout of T matches that of the data and if the data is already borrowed from Rust. If it’s not, the data is mutably derefenced and returned as a TrackedMut which provides direct access to the mutable reference.

Note that if T contains any references to Julia data, if such a reference is mutated through TrackedMut you must call write_barrier after mutating it. This ensures the garbage collector remains aware of old-generation objects pointing to young-generation objects.

In general, it’s recommended that only fields that contain no references to Julia data are updated through TrackedMut.

Safety:

This method can only track references that exist in Rust code. It also gives unrestricted mutable access to the contents of the data, which is inherently unsafe.

source

pub fn is_tracked(self) -> JlrsResult<bool>

Returns true if self is currently tracked.

source

pub fn is_tracked_shared(self) -> JlrsResult<bool>

Returns true if self is currently tracked.

source

pub fn is_tracked_exclusive(self) -> JlrsResult<bool>

Returns true if self is currently mutably tracked.

source§

impl Value<'static, 'static>

source

pub unsafe fn track_shared_unbound<T: ValidLayout + Send>( self ) -> JlrsResult<Tracked<'static, 'static, 'static, T>>

Track self immutably.

This method is equivalent to Value::track_shared except it takes self by value and can only be used with ValueUnbound. This is intended to be used from ccallable functions that take a Value and operate on its contents in another thread.

Because T: Send, it’s not possible to track types that contain references to Julia data.

Safety:

The returned instance of Tracked must only be used in the ccalled function and the AsyncCallback.

source

pub unsafe fn track_exclusive_unbound<T: ValidLayout + Send>( self ) -> JlrsResult<TrackedMut<'static, 'static, 'static, T>>

Track self exclusively.

This method is equivalent to Value::track_exclusive except it takes self by value and can only be used with ValueUnbound. This is intended to be used from ccallable functions that take a Value and operate on its contents in another thread.

Because T: Send, it’s not possible to track types that contain references to Julia data.

Safety:

The returned instance of TrackedMut must only be used in the ccalled function and the AsyncCallback.

source§

impl<'scope, 'data> Value<'scope, 'data>

Lifetime management

Values have two lifetimes, 'scope and 'data. The first ensures that a value can only be used while it’s rooted, 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 if it doesn’t borrow any data from Rust.

source

pub unsafe fn assume_owned(self) -> Value<'scope, 'static>

If you call a Julia 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 contain any borrowed data this function can be used to relax its second lifetime to 'static.

Safety: The value must not contain any data borrowed from Rust.

source§

impl<'scope, 'data> Value<'scope, 'data>

Conversions

There are two ways to convert a Value to some other type. The first is casting, which is used to convert a Value to the appropriate managed type. For example, if the Value is a Julia array it can be cast to Array. Because this only involves a pointer cast it’s always possible to convert a managed type to a Value by calling Managed::as_value. The second way is unboxing, which is used to copy the data the Value points to to Rust. If a Value is a UInt8, it can be unboxed as a u8. By default, jlrs can unbox the default primitive types and Julia strings, but the Unbox trait can be implemented for other types. It’s recommended that you use JlrsReflect.jl to do so. Unlike casting, unboxing dereferences the pointer. As a result it loses its header, so an unboxed value can’t be used as a Value again without reallocating it.

source

pub fn cast<T: Managed<'scope, 'data> + Typecheck>(self) -> JlrsResult<T>

Cast the value to a managed type T. Returns an error if the conversion is invalid.

source

pub unsafe fn cast_unchecked<T: Managed<'scope, 'data>>(self) -> T

Cast the value to a managed type T without checking if this conversion is valid.

Safety: You must guarantee self.is::<T>() would have returned true.

source

pub fn unbox<T: Unbox + Typecheck>(self) -> JlrsResult<T::Output>

Unbox the contents of the value as the output type associated with T. Returns an error if the layout of T::Output is incompatible with the layout of the type in Julia.

source

pub unsafe fn unbox_unchecked<T: Unbox>(self) -> T::Output

Unbox the contents of the value as the output type associated with T without checking if the layout of T::Output is compatible with the layout of the type in Julia.

Safety: You must guarantee self.is::<T>() would have returned true.

source

pub fn as_typed<'target, T: ConstructType, Tgt: Target<'target>>( self, target: &Tgt ) -> JlrsResult<TypedValue<'scope, 'data, T>>

Convert this value to a typed value if this value is an instance of the constructed type.

source

pub unsafe fn as_typed_unchecked<T: ConstructType>( self ) -> TypedValue<'scope, 'data, T>

Convert this value to a typed value without checking if the conversion is valid.

Safety: the converted value must be an instance of the constructed type.

source

pub fn data_ptr(self) -> NonNull<c_void>

Returns a pointer to the data, this is useful when the output type of Unbox is different than the implementation type and you have to write a custom unboxing function. It’s your responsibility this pointer is used correctly.

source§

impl<'scope, 'data> Value<'scope, 'data>

Fields

Most Julia values have fields. For example, if the value is an instance of this struct:

struct Example
   fielda
   fieldb::UInt32
end

it will have two fields, fielda and fieldb. The first field is a pointer field, the second is stored inline as a u32. It’s possible to safely access the raw contents of these fields with the method Value::field_accessor. The first field can be accessed as a ValueRef, the second as a u32.

source

pub fn field_names(self) -> &'scope [Symbol<'scope>]

Returns the field names of this value as a slice of Symbols.

source

pub fn n_fields(self) -> usize

Returns the number of fields the underlying Julia value has.

source

pub fn field_accessor(self) -> FieldAccessor<'scope, 'data>

Returns an accessor to access the contents of this value without allocating temporary Julia data.

source

pub fn get_nth_field<'target, T>( self, target: T, idx: usize ) -> JlrsResult<ValueData<'target, 'data, T>>where T: Target<'target>,

Roots the field at index idx if it exists and returns it, or a JlrsError::AccessError if the index is out of bounds.

source

pub fn get_nth_field_ref( self, idx: usize ) -> JlrsResult<ValueRef<'scope, 'data>>

Returns the field at index idx if it’s a pointer field.

If the field doesn’t exist or if the field can’t be referenced because its data is stored inline, a JlrsError::AccessError is returned.

source

pub fn get_field<'target, N, T>( self, target: T, field_name: N ) -> JlrsResult<ValueData<'target, 'data, T>>where N: ToSymbol, T: Target<'target>,

Roots the field with the name field_name if it exists and returns it, or a JlrsError::AccessError if there’s no field with that name.

source

pub fn get_field_ref<N>( self, field_name: N ) -> JlrsResult<Option<ValueRef<'scope, 'data>>>where N: ToSymbol,

Returns the field with the name field_name if it’s a pointer field.

If the field doesn’t exist or if the field can’t be referenced because its data is stored inline, a JlrsError::AccessError is returned.

source

pub unsafe fn set_nth_field<'target, T>( self, target: T, idx: usize, value: Value<'_, 'data> ) -> JlrsResult<TargetException<'target, 'data, (), T>>where T: Target<'target>,

Set the value of the field at idx. If Julia throws an exception it’s caught, rooted in the frame, and returned. If the index is out of bounds or the value is not a subtype of the field an error is returned,

Safety: Mutating things that should absolutely not be mutated, like the fields of a DataType, is not prevented.

source

pub unsafe fn set_nth_field_unchecked(self, idx: usize, value: Value<'_, 'data>)

Set the value of the field at idx. If Julia throws an exception the process aborts.

Safety: this method doesn’t check if the type of the value is a subtype of the field’s type. Mutating things that should absolutely not be mutated, like the fields of a DataType, is also not prevented.

source

pub unsafe fn set_field<'target, N, T>( self, target: T, field_name: N, value: Value<'_, 'data> ) -> JlrsResult<TargetException<'target, 'data, (), T>>where N: ToSymbol, T: Target<'target>,

Set the value of the field with the name field_name. If Julia throws an exception it’s caught, rooted in the frame, and returned. If there’s no field with the given name or the value is not a subtype of the field an error is returned.

Safety: Mutating things that should absolutely not be mutated, like the fields of a DataType, is not prevented.

source

pub unsafe fn set_field_unchecked<N>( self, field_name: N, value: Value<'_, 'data> ) -> JlrsResult<()>where N: ToSymbol,

Set the value of the field with the name field_name. If Julia throws an exception the process aborts. If there’s no field with the given name an error is returned.

Safety: this method doesn’t check if the type of the value is a subtype of the field’s type. Mutating things that should absolutely not be mutated, like the fields of a DataType, is also not prevented.

source§

impl Value<'_, '_>

Evaluate Julia code

The easiest way to call Julia from Rust is by evaluating some Julia code directly. This can be used to call simple functions without any arguments provided from Rust and to execute using-statements.

source

pub unsafe fn eval_string<'target, C, T>( target: T, cmd: C ) -> ValueResult<'target, 'static, T>where C: AsRef<str>, T: Target<'target>,

Execute a Julia command cmd, for example Value::eval_string(&mut *frame, "sqrt(2)") or Value::eval_string(&mut *frame, "using LinearAlgebra").

Safety: The command can’t be checked for correctness, nothing prevents you from causing a segmentation fault with a command like unsafe_load(Ptr{Float64}(C_NULL)).

source

pub unsafe fn eval_cstring<'target, C, T>( target: T, cmd: C ) -> ValueResult<'target, 'static, T>where C: AsRef<CStr>, T: Target<'target>,

Execute a Julia command cmd. This is equivalent to Value::eval_string, but uses a null-terminated string.

Safety: The command can’t be checked for correctness, nothing prevents you from causing a segmentation fault with a command like unsafe_load(Ptr{Float64}(C_NULL)).

source

pub unsafe fn include<'target, 'current, 'borrow, P, Tgt>( target: Tgt, path: P ) -> JlrsResult<ValueResult<'target, 'static, Tgt>>where P: AsRef<Path>, Tgt: Target<'target>,

Calls include in the Main module in Julia, which evaluates the file’s contents in that module. This has the same effect as calling include in the Julia REPL.

Safety: The content of the file can’t be checked for correctness, nothing prevents you from causing a segmentation fault with code like unsafe_load(Ptr{Float64}(C_NULL)).

source§

impl Value<'_, '_>

source

pub fn object_id(self) -> usize

Returns the object id of this value.

source

pub fn egal(self, other: Value<'_, '_>) -> bool

Returns true if self and other are equal.

source§

impl Value<'_, '_>

source

pub unsafe fn add_finalizer(self, f: Value<'_, 'static>)

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.

Safety: the finalizer must be compatible with the data.

source

pub unsafe fn add_ptr_finalizer(self, f: unsafe extern "C" fn(_: *mut c_void))

Add a finalizer f to this value. The finalizer must be an extern "C" function that takes one argument, the value as a void pointer.

Safety: the finalizer must be compatible with the data.

source§

impl<'scope> Value<'scope, 'static>

source

pub fn bottom_type<T>(_: &T) -> Selfwhere T: Target<'scope>,

Union{}.

source

pub fn stackovf_exception<T>(_: &T) -> Selfwhere T: Target<'scope>,

StackOverflowError.

source

pub fn memory_exception<T>(_: &T) -> Selfwhere T: Target<'scope>,

OutOfMemoryError.

source

pub fn readonlymemory_exception<T>(_: &T) -> Selfwhere T: Target<'scope>,

ReadOnlyMemoryError.

source

pub fn diverror_exception<T>(_: &T) -> Selfwhere T: Target<'scope>,

DivideError.

source

pub fn undefref_exception<T>(_: &T) -> Selfwhere T: Target<'scope>,

UndefRefError.

source

pub fn interrupt_exception<T>(_: &T) -> Selfwhere T: Target<'scope>,

InterruptException.

source

pub fn an_empty_vec_any<T>(_: &T) -> Selfwhere T: Target<'scope>,

An empty `Array{Any, 1}.

source

pub fn an_empty_string<T>(_: &T) -> Selfwhere T: Target<'scope>,

An empty immutable String, “”.

source

pub fn array_uint8_type<T>(_: &T) -> Selfwhere T: Target<'scope>,

Array{UInt8, 1}

source

pub fn array_any_type<T>(_: &T) -> Selfwhere T: Target<'scope>,

Array{Any, 1}

source

pub fn array_symbol_type<T>(_: &T) -> Selfwhere T: Target<'scope>,

Array{Symbol, 1}

source

pub fn array_int32_type<T>(_: &T) -> Selfwhere T: Target<'scope>,

Array{Int32, 1}

source

pub fn emptytuple<T>(_: &T) -> Selfwhere T: Target<'scope>,

The empty tuple, ().

source

pub fn true_v<T>(_: &T) -> Selfwhere T: Target<'scope>,

The instance of true.

source

pub fn false_v<T>(_: &T) -> Selfwhere T: Target<'scope>,

The instance of false.

source

pub fn nothing<T>(_: &T) -> Selfwhere T: Target<'scope>,

The instance of Nothing, nothing.

source

pub fn stdout<T>(_: &T) -> Selfwhere T: Target<'scope>,

The handle to stdout as a Julia value.

source

pub fn stderr<T>(_: &T) -> Selfwhere T: Target<'scope>,

The handle to stderr as a Julia value.

source

pub fn pair_type<T>(_: &T) -> Selfwhere T: Target<'scope>,

The Pair type

Trait Implementations§

source§

impl<'scope, 'data> CCallArg for Value<'scope, 'data>

§

type CCallArgType = Value<'static, 'static>

Type constructor for the type taken by the generated Julia function.
§

type FunctionArgType = Value<'scope, 'data>

Type constructor for the type taken by the ccalled function.
source§

impl<'data> Call<'data> for Value<'_, 'data>

source§

unsafe fn call0<'target, T>(self, target: T) -> ValueResult<'target, 'data, T>where T: Target<'target>,

Call a function with no arguments. Read more
source§

unsafe fn call_unchecked<'target, 'value, V, T, const N: usize>( self, target: T, args: V ) -> ValueData<'target, 'data, T>where V: Values<'value, 'data, N>, T: Target<'target>,

source§

unsafe fn call1<'target, T>( self, target: T, arg0: Value<'_, 'data> ) -> ValueResult<'target, 'data, T>where T: Target<'target>,

Call a function with one argument. Read more
source§

unsafe fn call2<'target, T>( self, target: T, arg0: Value<'_, 'data>, arg1: Value<'_, 'data> ) -> ValueResult<'target, 'data, T>where T: Target<'target>,

Call a function with two arguments. Read more
source§

unsafe fn call3<'target, T>( self, target: T, arg0: Value<'_, 'data>, arg1: Value<'_, 'data>, arg2: Value<'_, 'data> ) -> ValueResult<'target, 'data, T>where T: Target<'target>,

Call a function with three arguments. Read more
source§

unsafe fn call<'target, 'value, V, T, const N: usize>( self, target: T, args: V ) -> ValueResult<'target, 'data, T>where V: Values<'value, 'data, N>, T: Target<'target>,

Call a function with an arbitrary number arguments. Read more
source§

unsafe fn call_tracked<'target, 'value, V, T>( self, target: T, args: V ) -> JlrsResult<ValueResult<'target, 'data, T>>where V: AsRef<[Value<'value, 'data>]>, T: Target<'target>,

Call a function with an arbitrary number arguments. Read more
source§

impl<'data> CallAsync<'data> for Value<'_, 'data>

source§

unsafe fn call_async<'target, 'value, 'life0, 'async_trait, V, const N: usize>( self, frame: &'life0 mut AsyncGcFrame<'target>, args: V ) -> Pin<Box<dyn Future<Output = JuliaResult<'target, 'data>> + 'async_trait>>where V: Values<'value, 'data, N> + 'async_trait, Self: 'async_trait, 'target: 'async_trait, 'value: 'async_trait, 'life0: 'async_trait,

Creates and schedules a new task with Base.Threads.@spawn, and returns a future that resolves when this task is finished. Read more
source§

unsafe fn call_async_interactive<'target, 'value, 'life0, 'async_trait, V, const N: usize>( self, frame: &'life0 mut AsyncGcFrame<'target>, args: V ) -> Pin<Box<dyn Future<Output = JuliaResult<'target, 'data>> + 'async_trait>>where V: Values<'value, 'data, N> + 'async_trait, Self: 'async_trait, 'target: 'async_trait, 'value: 'async_trait, 'life0: 'async_trait,

Call a function on another thread with the given arguments. This method uses Base.Threads.@spawn to call the given function on another thread but return immediately. While awaiting the result the async runtime can work on other tasks, the current task resumes after the function call on the other thread completes. Read more
source§

unsafe fn schedule_async_interactive<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V ) -> JuliaResult<'target, 'data, Task<'target>>where V: Values<'value, 'data, N>,

Does the same thing as CallAsync::call_async, but the task is returned rather than an awaitable Future. This method should only be called in PersistentTask::init, otherwise it’s not guaranteed this task can make progress. Read more
source§

unsafe fn schedule_async<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V ) -> JuliaResult<'target, 'data, Task<'target>>where V: Values<'value, 'data, N>,

Does the same thing as CallAsync::call_async, but the task is returned rather than an awaitable Future. This method should only be called in PersistentTask::init, otherwise it’s not guaranteed this task can make progress. Read more
source§

unsafe fn call_async_local<'target, 'value, 'life0, 'async_trait, V, const N: usize>( self, frame: &'life0 mut AsyncGcFrame<'target>, args: V ) -> Pin<Box<dyn Future<Output = JuliaResult<'target, 'data>> + 'async_trait>>where V: Values<'value, 'data, N> + 'async_trait, Self: 'async_trait, 'target: 'async_trait, 'value: 'async_trait, 'life0: 'async_trait,

Call a function with the given arguments in an @async block. Like call_async, the function is not called on the main thread, but on a separate thread that handles all tasks created by this method. This method should only be used with functions that do very little computational work but mostly spend their time waiting on IO. Read more
source§

unsafe fn schedule_async_local<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V ) -> JuliaResult<'target, 'data, Task<'target>>where V: Values<'value, 'data, N>,

Does the same thing as CallAsync::call_async_local, but the task is returned rather than an awaitable Future. This method should only be called in PersistentTask::init, otherwise it’s not guaranteed this task can make progress. Read more
source§

unsafe fn call_async_main<'target, 'value, 'life0, 'async_trait, V, const N: usize>( self, frame: &'life0 mut AsyncGcFrame<'target>, args: V ) -> Pin<Box<dyn Future<Output = JuliaResult<'target, 'data>> + 'async_trait>>where V: Values<'value, 'data, N> + 'async_trait, Self: 'async_trait, 'target: 'async_trait, 'value: 'async_trait, 'life0: 'async_trait,

Call a function with the given arguments in an @async block. The task is scheduled on the main thread. This method should only be used with functions that must run on the main thread. The runtime is blocked while this task is active. Read more
source§

unsafe fn schedule_async_main<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V ) -> JuliaResult<'target, 'data, Task<'target>>where V: Values<'value, 'data, N>,

Does the same thing as CallAsync::call_async_main, but the task is returned rather than an awaitable Future. This method should only be called in PersistentTask::init, otherwise it’s not guaranteed this task can make progress. Read more
source§

unsafe fn call_async_tracked<'target, 'value, 'life0, 'async_trait, V, const N: usize>( self, frame: &'life0 mut AsyncGcFrame<'target>, args: V ) -> Pin<Box<dyn Future<Output = JlrsResult<JuliaResult<'target, 'data>>> + 'async_trait>>where V: Values<'value, 'data, N> + 'async_trait, Self: 'async_trait, 'target: 'async_trait, 'value: 'async_trait, 'life0: 'async_trait,

Creates and schedules a new task with Base.Threads.@spawn, and returns a future that resolves when this task is finished. Read more
source§

unsafe fn schedule_async_tracked<'target, 'value, V, T, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V ) -> JlrsResult<JuliaResult<'target, 'data, Task<'target>>>where V: Values<'value, 'data, N>, T: Target<'target>,

Does the same thing as CallAsync::call_async, but the task is returned rather than an awaitable Future. This method should only be called in PersistentTask::init, otherwise it’s not guaranteed this task can make progress. Read more
source§

unsafe fn call_async_interactive_tracked<'target, 'value, 'life0, 'async_trait, V, const N: usize>( self, frame: &'life0 mut AsyncGcFrame<'target>, args: V ) -> Pin<Box<dyn Future<Output = JlrsResult<JuliaResult<'target, 'data>>> + 'async_trait>>where V: Values<'value, 'data, N> + 'async_trait, Self: 'async_trait, 'target: 'async_trait, 'value: 'async_trait, 'life0: 'async_trait,

Call a function on another thread with the given arguments. This method uses Base.Threads.@spawn to call the given function on another thread but return immediately. While awaiting the result the async runtime can work on other tasks, the current task resumes after the function call on the other thread completes. Read more
source§

unsafe fn schedule_async_interactive_tracked<'target, 'value, V, T, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V ) -> JlrsResult<JuliaResult<'target, 'data, Task<'target>>>where V: Values<'value, 'data, N>, T: Target<'target>,

Does the same thing as CallAsync::call_async, but the task is returned rather than an awaitable Future. This method should only be called in PersistentTask::init, otherwise it’s not guaranteed this task can make progress. Read more
source§

unsafe fn call_async_local_tracked<'target, 'value, 'life0, 'async_trait, V, const N: usize>( self, frame: &'life0 mut AsyncGcFrame<'target>, args: V ) -> Pin<Box<dyn Future<Output = JlrsResult<JuliaResult<'target, 'data>>> + 'async_trait>>where V: Values<'value, 'data, N> + 'async_trait, Self: 'async_trait, 'target: 'async_trait, 'value: 'async_trait, 'life0: 'async_trait,

Call a function with the given arguments in an @async block. Like call_async, the function is not called on the main thread, but on a separate thread that handles all tasks created by this method. This method should only be used with functions that do very little computational work but mostly spend their time waiting on IO. Read more
source§

unsafe fn schedule_async_local_tracked<'target, 'value, V, T, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V ) -> JlrsResult<JuliaResult<'target, 'data, Task<'target>>>where V: Values<'value, 'data, N>, T: Target<'target>,

Does the same thing as CallAsync::call_async_local, but the task is returned rather than an awaitable Future. This method should only be called in PersistentTask::init, otherwise it’s not guaranteed this task can make progress. Read more
source§

unsafe fn call_async_main_tracked<'target, 'value, 'life0, 'async_trait, V, const N: usize>( self, frame: &'life0 mut AsyncGcFrame<'target>, args: V ) -> Pin<Box<dyn Future<Output = JlrsResult<JuliaResult<'target, 'data>>> + 'async_trait>>where V: Values<'value, 'data, N> + 'async_trait, Self: 'async_trait, 'target: 'async_trait, 'value: 'async_trait, 'life0: 'async_trait,

Call a function with the given arguments in an @async block. The task is scheduled on the main thread. This method should only be used with functions that must run on the main thread. The runtime is blocked while this task is active. Read more
source§

unsafe fn schedule_async_main_tracked<'target, 'value, V, T, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V ) -> JlrsResult<JuliaResult<'target, 'data, Task<'target>>>where V: Values<'value, 'data, N>, T: Target<'target>,

Does the same thing as CallAsync::call_async_main, but the task is returned rather than an awaitable Future. This method should only be called in PersistentTask::init, otherwise it’s not guaranteed this task can make progress. Read more
source§

impl<'scope, 'data> Clone for Value<'scope, 'data>

source§

fn clone(&self) -> Value<'scope, 'data>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl ConstructType for Value<'_, '_>

§

type Static = Value<'static, 'static>

Self, but with all lifetimes set to 'static.
source§

const CACHEABLE: bool = false

Indicates whether the type might be cacheable. Read more
source§

fn construct_type_uncached<'target, 'current, 'borrow, Tgt>( target: Tgt ) -> ValueData<'target, 'static, Tgt>where Tgt: Target<'target>,

Constructs the type object associated with this type.
source§

fn base_type<'target, Tgt>(_target: &Tgt) -> Option<Value<'target, 'static>>where Tgt: Target<'target>,

Returns the base type object associated with this type. Read more
source§

fn type_id() -> TypeId

Returns the TypeId of this type.
source§

fn construct_type<'target, T>(target: T) -> ValueData<'target, 'static, T>where T: Target<'target>,

Construct the type object and try to cache the result. If a cached entry is available, it is returned.
source§

impl Debug for Value<'_, '_>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'scope, 'data, T: Managed<'scope, 'data>> PartialEq<T> for Value<'_, '_>

source§

fn eq(&self, other: &T) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'scope, 'data> PartialEq<Value<'scope, 'data>> for DataType<'scope>

source§

fn eq(&self, other: &Value<'scope, 'data>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'value, 'data> ProvideKeywords<'value, 'data> for Value<'value, 'data>

source§

fn provide_keywords( self, kws: Value<'value, 'data> ) -> JlrsResult<WithKeywords<'value, 'data>>

Provide keyword arguments to the function. The keyword arguments must be a NamedTuple. Read more
source§

impl Typecheck for Value<'_, '_>

source§

fn typecheck(_: DataType<'_>) -> bool

Returns whether the property implied by Self holds true.
source§

impl ValidLayout for Value<'static, 'static>

source§

fn valid_layout(v: Value<'_, '_>) -> bool

Check if the layout of the implementor is compatible with the layout of ty. Read more
source§

fn type_object<'target, Tgt: Target<'target>>( target: &Tgt ) -> Value<'target, 'static>

source§

const IS_REF: bool = true

Must be true if the Rust type is a managed type.
source§

impl<'scope, 'data> Copy for Value<'scope, 'data>

source§

impl<'scope, 'data> Eq for Value<'scope, 'data>

source§

impl<'scope, 'data> StructuralEq for Value<'scope, 'data>

Auto Trait Implementations§

§

impl<'scope, 'data> RefUnwindSafe for Value<'scope, 'data>

§

impl<'scope, 'data> !Send for Value<'scope, 'data>

§

impl<'scope, 'data> !Sync for Value<'scope, 'data>

§

impl<'scope, 'data> Unpin for Value<'scope, 'data>

§

impl<'scope, 'data> !UnwindSafe for Value<'scope, 'data>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CompatibleCast for Twhere T: ValidLayout,

§

type Inner = T

§

type Output<U> = U

source§

fn compatible_cast<U>(&self) -> &<T as CompatibleCast>::Output<U>where T: Compatible<U>,

Converts &Self to &U, &[Self] to &[U], and &[Self; N] to &[U; N].
source§

fn compatible_cast_mut<U>(&mut self) -> &mut <T as CompatibleCast>::Output<U>where T: Compatible<U>,

Converts &mut Self to &mut U, &mut [Self] to &mut [U], and &mut [Self; N] to &mut [U; N].
§

impl<T> Conv for T

§

fn conv<T>(self) -> Twhere Self: Into<T>,

Converts self into T using Into<T>. Read more
§

impl<T> FmtForward for T

§

fn fmt_binary(self) -> FmtBinary<Self>where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
§

fn fmt_display(self) -> FmtDisplay<Self>where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
§

fn fmt_octal(self) -> FmtOctal<Self>where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
§

fn fmt_pointer(self) -> FmtPointer<Self>where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
§

fn fmt_list(self) -> FmtList<Self>where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<'scope, 'data, T> HasLayout<'scope, 'data> for Twhere T: ConstructType + ValidLayout,

§

type Layout = T

The layout associated with this type constructor.
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<'scope, 'data, W> Managed<'scope, 'data> for Wwhere W: ManagedPriv<'scope, 'data>,

§

type TypeConstructor<'target, 'da> = <W as ManagedPriv<'scope, 'data>>::TypeConstructorPriv<'target, 'da>

Self, but with arbitrary lifetimes. Used to construct the appropriate type in generic contexts.
source§

fn as_ref(self) -> Ref<'scope, 'data, Self>

Convert the data to a Ref.
source§

fn as_value(self) -> Value<'scope, 'data>

Convert the data to a Value.
source§

fn root<'target, T>( self, target: T ) -> T::Data<'data, Self::TypeConstructor<'target, 'data>>where T: Target<'target>,

Use the target to reroot this data.
source§

fn unrooted_target(self) -> Unrooted<'scope>

Returns a new Unrooted.
source§

fn display_string(self) -> JlrsResult<String>

Convert the data to its display string, i.e. the string that is shown when calling Base.show.
source§

fn error_string(self) -> JlrsResult<String>

Convert the data to its error string, i.e. the string that is shown when calling Base.showerror. This string can contain ANSI color codes if this is enabled by calling Julia::error_color or AsyncJulia::error_color.
source§

fn display_string_or<S: Into<String>>(self, default: S) -> String

Convert the data to its display string, i.e. the string that is shown by calling Base.display, or some default value.
source§

fn error_string_or<S: Into<String>>(self, default: S) -> String

Convert the data to its error string, i.e. the string that is shown when this value is thrown as an exception, or some default value.
source§

fn leak(self) -> Ref<'static, 'data, Self::TypeConstructor<'static, 'data>>

Extends the 'scope lifetime to 'static, which allows this managed data to be leaked from a scope. Read more
§

impl<T> Pipe for Twhere T: ?Sized,

§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> Rwhere Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> Rwhere Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R ) -> Rwhere Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
§

impl<T> Tap for T

§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Selfwhere Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T> TryConv for T

§

fn try_conv<T>(self) -> Result<T, Self::Error>where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> Compatible<T> for Twhere T: ValidLayout,