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> ArrayBuf<Tag>
impl<Tag> ArrayBuf<Tag>
Sourcepub fn new(
data_type: Tag,
dimensions: Vec<usize>,
bytes: Vec<u8>,
) -> ArrayBuf<Tag>
pub fn new( data_type: Tag, dimensions: Vec<usize>, bytes: Vec<u8>, ) -> ArrayBuf<Tag>
Construct from raw parts. Caller is responsible for ensuring
bytes.len() == prod(dimensions) * element_size.
Sourcepub fn dimensions(&self) -> &[usize]
pub fn dimensions(&self) -> &[usize]
Multi-dimensional shape.
Sourcepub fn element_count(&self) -> usize
pub fn element_count(&self) -> usize
Total element count = product of dimensions.
Sourcepub fn from_slice<T>(dimensions: Vec<usize>, slice: &[T]) -> ArrayBuf<Tag>where
T: ArrayElement<Tag>,
pub fn from_slice<T>(dimensions: Vec<usize>, slice: &[T]) -> ArrayBuf<Tag>where
T: ArrayElement<Tag>,
Construct from a typed slice. Dimensions must satisfy
prod(dimensions) == slice.len().
Sourcepub fn try_as_slice<T>(&self) -> Option<&[T]>where
T: ArrayElement<Tag>,
pub fn try_as_slice<T>(&self) -> Option<&[T]>where
T: ArrayElement<Tag>,
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§
impl<Tag> Eq for ArrayBuf<Tag>where
Tag: Eq,
Source§impl<T> From<(Vec<usize>, &[T])> for ArrayBuf<PackedArrayEnum>where
T: ArrayElement<PackedArrayEnum>,
impl<T> From<(Vec<usize>, &[T])> for ArrayBuf<PackedArrayEnum>where
T: ArrayElement<PackedArrayEnum>,
Source§impl<'de> FromWXF<'de> for ArrayBuf<NumericArrayEnum>
impl<'de> FromWXF<'de> for ArrayBuf<NumericArrayEnum>
Source§impl<'de> FromWXF<'de> for ArrayBuf<PackedArrayEnum>
impl<'de> FromWXF<'de> for ArrayBuf<PackedArrayEnum>
Source§impl<Tag> NumericArrayRead for ArrayBuf<Tag>
impl<Tag> NumericArrayRead for ArrayBuf<Tag>
Source§fn data_type(&self) -> NumericArrayEnum
fn data_type(&self) -> NumericArrayEnum
The element-type tag.
Source§fn dimensions(&self) -> &[usize]
fn dimensions(&self) -> &[usize]
The multi-dimensional shape (row-major).
Source§fn element_count(&self) -> usize
fn element_count(&self) -> usize
Total element count = product of dimensions.
Source§fn try_as_slice<T>(&self) -> Option<&[T]>where
T: ArrayElement<NumericArrayEnum>,
fn try_as_slice<T>(&self) -> Option<&[T]>where
T: ArrayElement<NumericArrayEnum>,
View the buffer as
&[T] if T’s element type matches; else None.Source§impl<Tag> Ord for ArrayBuf<Tag>where
Tag: Ord,
impl<Tag> Ord for ArrayBuf<Tag>where
Tag: Ord,
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<Tag> PartialOrd for ArrayBuf<Tag>where
Tag: PartialOrd,
impl<Tag> PartialOrd for ArrayBuf<Tag>where
Tag: PartialOrd,
impl<Tag> StructuralPartialEq for ArrayBuf<Tag>where
Tag: PartialEq,
Source§impl ToWXF for ArrayBuf<NumericArrayEnum>
impl ToWXF for ArrayBuf<NumericArrayEnum>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more