Skip to main content

FromArrayBytes

Trait FromArrayBytes 

Source
pub trait FromArrayBytes: Sized {
    // Required method
    fn from_array_bytes(
        bytes: ArrayBytes<'static>,
        shape: &[u64],
        data_type: &DataType,
    ) -> Result<Self, ArrayError>;

    // Provided method
    fn from_array_bytes_arc(
        bytes: Arc<ArrayBytes<'static>>,
        shape: &[u64],
        data_type: &DataType,
    ) -> Result<Self, ArrayError> { ... }
}
Expand description

A trait for types that can be constructed from ArrayBytes, an array shape and a DataType.

Required Methods§

Source

fn from_array_bytes( bytes: ArrayBytes<'static>, shape: &[u64], data_type: &DataType, ) -> Result<Self, ArrayError>

Convert ArrayBytes into Self.

§Arguments
  • bytes - The array bytes to convert
  • shape - The shape of the array
  • data_type - The datatype of the array elements
§Errors

Returns an ArrayError if the conversion fails.

Provided Methods§

Source

fn from_array_bytes_arc( bytes: Arc<ArrayBytes<'static>>, shape: &[u64], data_type: &DataType, ) -> Result<Self, ArrayError>

Convert an Arc<ArrayBytes> into Self.

This method has a default implementation that unwraps the Arc (cloning if necessary). It is overridden for Arc<ArrayBytes<'static>> to avoid the clone. This is used by cached retrieval methods to avoid unnecessary copies.

§Arguments
  • bytes - The array bytes to convert (wrapped in Arc)
  • shape - The shape of the array
  • data_type - The datatype of the array elements
§Errors

Returns an ArrayError if the conversion fails.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl FromArrayBytes for Arc<ArrayBytes<'static>>

Source§

fn from_array_bytes( bytes: ArrayBytes<'static>, _shape: &[u64], _data_type: &DataType, ) -> Result<Self, ArrayError>

Source§

fn from_array_bytes_arc( bytes: Arc<ArrayBytes<'static>>, _shape: &[u64], _data_type: &DataType, ) -> Result<Self, ArrayError>

Source§

impl<T: ElementOwned> FromArrayBytes for Vec<T>

Source§

fn from_array_bytes( bytes: ArrayBytes<'static>, _shape: &[u64], data_type: &DataType, ) -> Result<Self, ArrayError>

Source§

impl<T: ElementOwned, D: Dimension> FromArrayBytes for Array<T, D>

Available on crate feature ndarray only.
Source§

fn from_array_bytes( bytes: ArrayBytes<'static>, shape: &[u64], data_type: &DataType, ) -> Result<Self, ArrayError>

Implementors§