Skip to main content

ArrayBuf

Struct ArrayBuf 

Source
pub struct ArrayBuf<Tag> { /* private fields */ }
Expand description

Generic dense N-dimensional buffer parameterized by an element-type tag.

NumericArray = ArrayBuf<NumericArrayEnum> and PackedArray = ArrayBuf<PackedArrayEnum>. Each provides specialized constructors (from_slice<T: …Element>) and a typed slice view; shape, byte access, and element count are shared via this struct.

Implementations§

Source§

impl<Tag: Copy + PartialEq> ArrayBuf<Tag>

Source

pub fn new(data_type: Tag, dimensions: Vec<usize>, bytes: ByteArray) -> Self

Construct from raw parts. Caller is responsible for ensuring bytes.len() == prod(dimensions) * element_size.

Source

pub fn data_type(&self) -> Tag

The concrete element-type tag.

Source

pub fn dimensions(&self) -> &[usize]

Multi-dimensional shape.

Source

pub fn as_bytes(&self) -> &[u8]

Raw byte buffer.

Source

pub fn rank(&self) -> usize

Number of dimensions.

Source

pub fn element_count(&self) -> usize

Total element count = product of dimensions.

Source

pub fn byte_count(&self) -> usize

Total byte length of the buffer.

Source

pub fn from_slice<T: ArrayElement<Tag>>( dimensions: Vec<usize>, slice: &[T], ) -> Self

Construct from a typed slice. Dimensions must satisfy prod(dimensions) == slice.len().

Source

pub fn try_as_slice<T: ArrayElement<Tag>>(&self) -> Option<&[T]>

Try to view the buffer as a slice of T. Returns None if T’s tag doesn’t match this array’s data_type.

Trait Implementations§

Source§

impl<Tag: Clone> Clone for ArrayBuf<Tag>

Source§

fn clone(&self) -> ArrayBuf<Tag>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Tag: Debug> Debug for ArrayBuf<Tag>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Tag: Eq> Eq for ArrayBuf<Tag>

Source§

impl From<ArrayBuf<NumericArrayEnum>> for Expr

Source§

fn from(a: NumericArray) -> Expr

Converts to this type from the input type.
Source§

impl From<ArrayBuf<PackedArrayEnum>> for Expr

Source§

fn from(a: PackedArray) -> Expr

Converts to this type from the input type.
Source§

impl<Tag: Hash> Hash for ArrayBuf<Tag>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<Tag: Into<NumericArrayEnum> + Copy + PartialEq> NumericArrayRead for ArrayBuf<Tag>

Source§

fn data_type(&self) -> NumericArrayEnum

The element-type tag.
Source§

fn dimensions(&self) -> &[usize]

The multi-dimensional shape (row-major).
Source§

fn as_bytes(&self) -> &[u8]

The flat little-endian byte buffer.
Source§

fn rank(&self) -> usize

Number of dimensions.
Source§

fn element_count(&self) -> usize

Total element count = product of dimensions.
Source§

fn byte_count(&self) -> usize

Total byte length of the buffer.
Source§

fn element_size(&self) -> usize

Bytes per element.
Source§

fn try_as_slice<T: ArrayElement<NumericArrayEnum>>(&self) -> Option<&[T]>

View the buffer as &[T] if T’s element type matches; else None.
Source§

impl<Tag: Ord> Ord for ArrayBuf<Tag>

Source§

fn cmp(&self, other: &ArrayBuf<Tag>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<Tag: PartialEq> PartialEq for ArrayBuf<Tag>

Source§

fn eq(&self, other: &ArrayBuf<Tag>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Tag: PartialOrd> PartialOrd for ArrayBuf<Tag>

Source§

fn partial_cmp(&self, other: &ArrayBuf<Tag>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<Tag> StructuralPartialEq for ArrayBuf<Tag>

Auto Trait Implementations§

§

impl<Tag> Freeze for ArrayBuf<Tag>
where Tag: Freeze,

§

impl<Tag> RefUnwindSafe for ArrayBuf<Tag>
where Tag: RefUnwindSafe,

§

impl<Tag> Send for ArrayBuf<Tag>
where Tag: Send,

§

impl<Tag> Sync for ArrayBuf<Tag>
where Tag: Sync,

§

impl<Tag> Unpin for ArrayBuf<Tag>
where Tag: Unpin,

§

impl<Tag> UnsafeUnpin for ArrayBuf<Tag>
where Tag: UnsafeUnpin,

§

impl<Tag> UnwindSafe for ArrayBuf<Tag>
where Tag: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.