arrow::datatypes

Trait ArrowNativeType

pub trait ArrowNativeType:
    Debug
    + Send
    + Sync
    + Copy
    + PartialOrd
    + Default
    + Sealed
    + 'static {
    // Required methods
    fn from_usize(_: usize) -> Option<Self>;
    fn as_usize(self) -> usize;
    fn usize_as(i: usize) -> Self;
    fn to_usize(self) -> Option<usize>;
    fn to_isize(self) -> Option<isize>;
    fn to_i64(self) -> Option<i64>;

    // Provided methods
    fn get_byte_width() -> usize { ... }
    fn from_i32(_: i32) -> Option<Self> { ... }
    fn from_i64(_: i64) -> Option<Self> { ... }
    fn from_i128(_: i128) -> Option<Self> { ... }
}
Expand description

Trait expressing a Rust type that has the same in-memory representation as Arrow.

This includes i16, f32, but excludes bool (which in arrow is represented in bits).

In little endian machines, types that implement ArrowNativeType can be memcopied to arrow buffers as is.

§Transmute Safety

A type T implementing this trait means that any arbitrary slice of bytes of length and alignment size_of::<T>() can be safely interpreted as a value of that type without being unsound, i.e. potentially resulting in undefined behaviour.

Note: in the case of floating point numbers this transmutation can result in a signalling NaN, which, whilst sound, can be unwieldy. In general, whilst it is perfectly sound to reinterpret bytes as different types using this trait, it is likely unwise. For more information see f32::from_bits and f64::from_bits.

Note: bool is restricted to 0 or 1, and so bool: !ArrowNativeType

§Sealed

Due to the above restrictions, this trait is sealed to prevent accidental misuse

Required Methods§

fn from_usize(_: usize) -> Option<Self>

Convert native integer type from usize

Returns None if Self is not an integer or conversion would result in truncation/overflow

fn as_usize(self) -> usize

Convert to usize according to the as operator

fn usize_as(i: usize) -> Self

Convert from usize according to the as operator

fn to_usize(self) -> Option<usize>

Convert native type to usize.

Returns None if Self is not an integer or conversion would result in truncation/overflow

fn to_isize(self) -> Option<isize>

Convert native type to isize.

Returns None if Self is not an integer or conversion would result in truncation/overflow

fn to_i64(self) -> Option<i64>

Convert native type to i64.

Returns None if Self is not an integer or conversion would result in truncation/overflow

Provided Methods§

fn get_byte_width() -> usize

Returns the byte width of this native type.

fn from_i32(_: i32) -> Option<Self>

👎Deprecated: please use Option::Some instead

Convert native type from i32.

Returns None if Self is not i32

fn from_i64(_: i64) -> Option<Self>

👎Deprecated: please use Option::Some instead

Convert native type from i64.

Returns None if Self is not i64

fn from_i128(_: i128) -> Option<Self>

👎Deprecated: please use Option::Some instead

Convert native type from i128.

Returns None if Self is not i128

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

§

impl ArrowNativeType for f32

§

fn from_usize(_: usize) -> Option<f32>

§

fn to_usize(self) -> Option<usize>

§

fn to_isize(self) -> Option<isize>

§

fn to_i64(self) -> Option<i64>

§

fn as_usize(self) -> usize

§

fn usize_as(i: usize) -> f32

§

impl ArrowNativeType for f64

§

fn from_usize(_: usize) -> Option<f64>

§

fn to_usize(self) -> Option<usize>

§

fn to_isize(self) -> Option<isize>

§

fn to_i64(self) -> Option<i64>

§

fn as_usize(self) -> usize

§

fn usize_as(i: usize) -> f64

§

impl ArrowNativeType for i8

§

fn from_usize(v: usize) -> Option<i8>

§

fn to_usize(self) -> Option<usize>

§

fn to_isize(self) -> Option<isize>

§

fn to_i64(self) -> Option<i64>

§

fn as_usize(self) -> usize

§

fn usize_as(i: usize) -> i8

§

impl ArrowNativeType for i16

§

fn from_usize(v: usize) -> Option<i16>

§

fn to_usize(self) -> Option<usize>

§

fn to_isize(self) -> Option<isize>

§

fn to_i64(self) -> Option<i64>

§

fn as_usize(self) -> usize

§

fn usize_as(i: usize) -> i16

§

impl ArrowNativeType for i32

§

fn from_usize(v: usize) -> Option<i32>

§

fn to_usize(self) -> Option<usize>

§

fn to_isize(self) -> Option<isize>

§

fn to_i64(self) -> Option<i64>

§

fn as_usize(self) -> usize

§

fn usize_as(i: usize) -> i32

§

fn from_i32(v: i32) -> Option<i32>

👎Deprecated: please use Option::Some instead
§

impl ArrowNativeType for i64

§

fn from_usize(v: usize) -> Option<i64>

§

fn to_usize(self) -> Option<usize>

§

fn to_isize(self) -> Option<isize>

§

fn to_i64(self) -> Option<i64>

§

fn as_usize(self) -> usize

§

fn usize_as(i: usize) -> i64

§

fn from_i64(v: i64) -> Option<i64>

👎Deprecated: please use Option::Some instead
§

impl ArrowNativeType for i128

§

fn from_usize(v: usize) -> Option<i128>

§

fn to_usize(self) -> Option<usize>

§

fn to_isize(self) -> Option<isize>

§

fn to_i64(self) -> Option<i64>

§

fn as_usize(self) -> usize

§

fn usize_as(i: usize) -> i128

§

fn from_i128(v: i128) -> Option<i128>

👎Deprecated: please use Option::Some instead
§

impl ArrowNativeType for u8

§

fn from_usize(v: usize) -> Option<u8>

§

fn to_usize(self) -> Option<usize>

§

fn to_isize(self) -> Option<isize>

§

fn to_i64(self) -> Option<i64>

§

fn as_usize(self) -> usize

§

fn usize_as(i: usize) -> u8

§

impl ArrowNativeType for u16

§

fn from_usize(v: usize) -> Option<u16>

§

fn to_usize(self) -> Option<usize>

§

fn to_isize(self) -> Option<isize>

§

fn to_i64(self) -> Option<i64>

§

fn as_usize(self) -> usize

§

fn usize_as(i: usize) -> u16

§

impl ArrowNativeType for u32

§

fn from_usize(v: usize) -> Option<u32>

§

fn to_usize(self) -> Option<usize>

§

fn to_isize(self) -> Option<isize>

§

fn to_i64(self) -> Option<i64>

§

fn as_usize(self) -> usize

§

fn usize_as(i: usize) -> u32

§

impl ArrowNativeType for u64

§

fn from_usize(v: usize) -> Option<u64>

§

fn to_usize(self) -> Option<usize>

§

fn to_isize(self) -> Option<isize>

§

fn to_i64(self) -> Option<i64>

§

fn as_usize(self) -> usize

§

fn usize_as(i: usize) -> u64

§

impl ArrowNativeType for u128

§

fn from_usize(v: usize) -> Option<u128>

§

fn to_usize(self) -> Option<usize>

§

fn to_isize(self) -> Option<isize>

§

fn to_i64(self) -> Option<i64>

§

fn as_usize(self) -> usize

§

fn usize_as(i: usize) -> u128

§

impl ArrowNativeType for f16

§

fn from_usize(_: usize) -> Option<f16>

§

fn to_usize(self) -> Option<usize>

§

fn to_isize(self) -> Option<isize>

§

fn to_i64(self) -> Option<i64>

§

fn as_usize(self) -> usize

§

fn usize_as(i: usize) -> f16

Implementors§