Trait ArrayBinaryBits

Source
pub trait ArrayBinaryBits
where Self: Sized + Clone,
{ // Required methods fn unpack_bits( &self, axis: Option<isize>, count: Option<isize>, bit_order: Option<impl BitOrderType>, ) -> Result<Array<u8>, ArrayError>; fn pack_bits( &self, axis: Option<isize>, bit_order: Option<impl BitOrderType>, ) -> Result<Array<u8>, ArrayError>; }
Expand description

ArrayTrait - Binary Array bits operations

Required Methods§

Source

fn unpack_bits( &self, axis: Option<isize>, count: Option<isize>, bit_order: Option<impl BitOrderType>, ) -> Result<Array<u8>, ArrayError>

Unpacks elements of a uint8 array into a binary-valued output array

§Arguments
  • axis - the dimension over which bit-unpacking is done. if none, array is flattened
  • count - the number of elements to unpack along axis. if negative, array is trimmed
  • bit_order - {big, little}, optional. defaults to big
§Examples
use arr_rs::prelude::*;

let expected = array!(u8, [[0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 0, 1, 1, 1]]);
let array = array!(u8, [[2], [7], [23]]);
assert_eq!(expected, array.unpack_bits(Some(1), None, Some("big")));
§Errors

may returns ArrayError

Source

fn pack_bits( &self, axis: Option<isize>, bit_order: Option<impl BitOrderType>, ) -> Result<Array<u8>, ArrayError>

Packs the elements of a binary-valued array into bits in a uint8 array

§Arguments
  • axis - the dimension over which bit-packing is done. if none, array is flattened
  • bit_order - {big, little}, optional. defaults to big
§Examples
use arr_rs::prelude::*;

let expected = array!(u8, [[2], [7], [23]]);
let array = array!(u8, [[0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 0, 1, 1, 1]]);
assert_eq!(expected, array.pack_bits(Some(1), Some("big")));
§Errors

may returns ArrayError

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 ArrayBinaryBits for Result<Array<u8>, ArrayError>

Source§

fn unpack_bits( &self, axis: Option<isize>, count: Option<isize>, bit_order: Option<impl BitOrderType>, ) -> Result<Array<u8>, ArrayError>

Source§

fn pack_bits( &self, axis: Option<isize>, bit_order: Option<impl BitOrderType>, ) -> Result<Array<u8>, ArrayError>

Implementors§