Struct jlrs::wrappers::ptr::array::Array[][src]

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

An n-dimensional Julia array. It can be used in combination with DataType::is and Value::is, if the check returns true the Value can be cast to Array:

julia.scope(|_global, frame| {
    let arr = Array::new::<f64, _, _, _>(&mut *frame, (3, 3))?
        .into_jlrs_result()?;

    assert!(arr.is::<Array>());
    assert!(arr.cast::<Array>().is_ok());
    Ok(())
}).unwrap();

Each element in the backing storage is either stored as a Value or inline. If the inline data is a bits union, the flag indicating the active variant is stored separately from the elements. You can check how the data is stored by calling Array::is_value_array, Array::is_inline_array, or Array::is_union_array.

Arrays that contain integers or floats are an example of inline arrays. Their data is stored as an array that contains numbers of the appropriate type, for example an array of Float32s in Julia is backed by an an array of f32s. The data in these arrays can be accessed with Array::inline_data and Array::inline_data_mut, and copied from Julia to Rust with Array::copy_inline_data. In order to call these methods the type of the elements must be provided, this type must implement ValidLayout to ensure the layouts in Rust and Julia are compatible.

If the data isn’t inlined each element is stored as a Value. This data can be accessed using Array::value_data and Array::value_data_mut.

Implementations

Allocates a new n-dimensional array in Julia of dimensions dims. If dims = (4, 2) a two-dimensional array with 4 rows and 2 columns is created. This method can only be used in combination with types that implement IntoJulia. If you want to create an array for a type that doesn’t implement this trait you must use Array::new_for.

If the array size is too large, Julia will throw an error. This error is caught and returned.

Allocates a new n-dimensional array in Julia of dimensions dims. If dims = (4, 2) a two-dimensional array with 4 rows and 2 columns is created. This method can only be used in combination with types that implement IntoJulia. If you want to create an array for a type that doesn’t implement this trait you must use Array::new_for.

If the array size is too large, the process will abort.

Allocates a new n-dimensional array in Julia for elements of type ty, which must be a Union, UnionAll or DataType, and dimensions dims. If dims = (4, 2) a two-dimensional array with 4 rows and 2 columns is created. If an exception is thrown due to either the type or dimensions being invalid it’s caught and returned.

Allocates a new n-dimensional array in Julia for elements of type ty, which must be a Union, UnionAll or DataType, and dimensions dims. If dims = (4, 2) a two-dimensional array with 4 rows and 2 columns is created. If an exception is thrown due to either the type or dimensions being invalid the process aborts.

Borrows an n-dimensional array from Rust for use in Julia with dimensions dims. If dims = (4, 2)` a two-dimensional array with 4 rows and 2 columns is created.

Moves an n-dimensional array from Rust for use in Julia with dimensions dims. If dims = (4, 2) a two-dimensional array with 4 rows and 2 columns is created.

Convert a string to an array.

Returns the array’s dimensions.

Returns the type of this array’s elements.

Returns true if the layout of the elements is compatible with T.

Returns true if the layout of the elements is compatible with T and these elements are stored inline.

Returns true if the elements of the array are stored inline.

Returns true if the elements of the array are stored inline and the element type is a union type. In this case the contents of the array can be accessed from Rust with Array::union_data and Array::union_data_mut.

Returns true if the elements of the array are stored inline and at least one of the fields of the inlined type is a pointer.

Returns true if elements of this array are zero-initialized.

Returns true if the elements of the array are stored as Values.

Convert this untyped array to a TypedArray.

Copy the data of an inline array to Rust. Returns JlrsError::NotInline if the data is not stored inline or JlrsError::WrongType if the type of the elements is incorrect.

Immutably borrow inline array data, you can borrow data from multiple arrays at the same time. Returns JlrsError::NotInline if the data is not stored inline or JlrsError::WrongType if the type of the elements is incorrect.

Mutably borrow inline array data, you can mutably borrow a single array at a time. Returns JlrsError::NotInline if the data is not stored inline or JlrsError::WrongType if the type of the elements is incorrect.

Mutably borrow inline array data without the restriction that only a single array can be mutably borrowed. It’s your responsibility to ensure you don’t create multiple mutable references to the same array data.

Returns JlrsError::NotInline if the data is not stored inline or JlrsError::WrongType if the type of the elements is incorrect.

Immutably borrow the data of this array of values, you can borrow data from multiple arrays at the same time. The values themselves can be mutable, but you can’t replace an element with another value. Returns JlrsError::Inline if the data is stored inline.

Immutably borrow the data of this array of wrappers, you can borrow data from multiple arrays at the same time. The values themselves can be mutable, but you can’t replace an element with another value. Returns JlrsError::Inline if the data is stored inline.

Mutably borrow the data of this array of values, you can mutably borrow a single array at the same time. Returns JlrsError::Inline if the data is stored inline.

Mutably borrow the data of this array of wrappers, you can mutably borrow a single array at the same time. Returns JlrsError::Inline if the data is stored inline.

Mutably borrow the data of this array of values without the restriction that only a single array can be mutably borrowed. It’s your responsibility to ensure you don’t create multiple mutable references to the same array data. Returns JlrsError::Inline if the data is stored inline.

Mutably borrow the data of this array of wrappers without the restriction that only a single array can be mutably borrowed. It’s your responsibility to ensure you don’t create multiple mutable references to the same array data. Returns JlrsError::Inline if the data is stored inline.

Access the contents of a bits-union array.

Mutably borrow the data of this array of bits-unions, you can mutably borrow a single array at a time.

Mutably borrow the data of this array of bits-unions without the restriction that only a single array can be mutably borrowed. It’s your responsibility to ensure you don’t create multiple mutable references to the same array data.

Reshape the array, a new array is returned that has dimensions dims. This new array and self share their data. This method returns an exception if the old and new array have a different number of elements or if the array contains data that has been borrowed or moved from Rust.

Inserts inc more elements at the end of the array. The array must be 1D and contain no data borrowed or moved from Rust, otherwise an exception is returned. Depending on the type of the array elements the newly added elements will either be left uninitialized, or their contents will be set to 0s. It’s set to 0s if DataType::zero_init returns true, if the elements are stored as pointers to Julia data, or if the elements contain pointers to Julia data.

Removes the final dec elements from the array. The array must be 1D and contain no data borrowed or moved from Rust, otherwise an exception is returned.

Inserts inc more elements at the beginning of the array. The array must be 1D and contain no data borrowed or moved from Rust, otherwise an exception is returned. Depending on the type of the array elements the newly added elements will either be left uninitialized, or their contents will be set to 0s. It’s set to 0s if DataType::zero_init returns true, if the elements are stored as pointers to Julia data, or if the elements contain pointers to Julia data.

Removes the first dec elements from the array. The array must be 1D and contain no data borrowed or moved from Rust, otherwise an exception is returned.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Borrow the data in the array as an ArrayView. Returns an error if the wrong type is provided or the data is not stored inline. Read more

Mutably borrow the data in the array as an ArrayViewMut. Returns an error if the wrong type is provided or the data is not stored inline. Read more

Check if the layout of the implementor is compatible with the layout of ty. This argument is a Value to account for the fact that a field type can be a Union, UnionAll or Union{}. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The reference type associated with this wrapper.

Convert the wrapper to a Ref.

Convert the wrapper to a Value.

Convert the wrapper to its display string, i.e. the string that is shown when calling Base.show. Read more

Convert the wrapper 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, AsyncJulia::error_color, or AsyncJulia::try_error_color, . Read more

Convert the wrapper to its display string, i.e. the string that is shown by calling Base.display, or some default value. Read more

Convert the wrapper to its error string, i.e. the string that is shown when this value is thrown as an exception, or some default value. Read more