jlrs 0.14 is compatible with Julia 1.7 by default. Support for Julia 1.6 can be enabled by enabling the lts
feature, support for Julia 1.8.0-rc1 by enabling the rc1
feature.
- Builders and runtimes
When Julia is embedded in a Rust application it must be initialized before it can be used. To do so a RuntimeBuilder
must be used. This builder lets you configure several options like a custom system image, the number of threads Julia can use, and the backing runtime and channel for an async runtime. Both the tokio-rt and async-std-rt feature can now be enabled simultaneously, you can implement your own backing runtime by implementing the AsyncRuntime
trait.
- Scopes
Methods that call the Julia C API can only be called from a scope. Every scope has its own GC frame which is used to root Julia data, ensuring it can be used until that scope ends. Previous versions of jlrs provided specific methods to create a scope that returns Julia data rooted in a parent scope. The major drawback of that approach was that every method that returned Julia data had to return it as a Value
. These custom methods have been removed. A method that returns rooted Julia data can be called with an Output
reserved in some GC frame or a mutable reference to the current GC frame, the lifetime of the returned data depends on which was used. This lifetime ensures the data can be returned from the scope as long as it has been rooted in an older frame.
As a result of this change, many methods now return Julia data of the correct type. For example Array::new
returns an Array
and JuliaString::new
a JuliaString
.
- FieldAccessor
The new FieldAccessor
allows accessing arbitrarily deeply nested data in a Value
directly, without boxing intermediate levels or needing to know their layout. The FieldAccessor
can handle arbitrary field types, including arrays and bits unions and supports accessing atomic fields.