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

    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§

Convert native integer type from usize

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

Convert to usize according to the as operator

Convert native type to usize.

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

Convert native type to isize.

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

Provided Methods§

👎Deprecated: please use Option::Some instead

Convert native type from i32.

Returns None if Self is not i32

👎Deprecated: please use Option::Some instead

Convert native type from i64.

Returns None if Self is not i64

👎Deprecated: please use Option::Some instead

Convert native type from i128.

Returns None if Self is not i128

Implementations on Foreign Types§

👎Deprecated: please use Option::Some instead
👎Deprecated: please use Option::Some instead
👎Deprecated: please use Option::Some instead

Implementors§