Skip to main content

ArrayData

Struct ArrayData 

Source
pub struct ArrayData {
    pub metadata: ArrayMetadata,
    pub values: ArrayValues,
}
Expand description

A block of numbers, as read, with the shape it came in.

§How many copies

Reading a compressed or chunked dataset cannot be done without the library materialising it somewhere, so one copy - from the file into the caller’s memory - is the floor. What this type is shaped to avoid is the second and third:

ArrayData::valuesfilled straight by the backend. One copy
ArrayValues::as_bytesa borrow of that same memory. Zero
ArrayData::f64 and friendsa borrow when the type already matches. Zero
ArrayData::to_f64widens every element. One more copy, and you asked for it

And crate::ArrayBackend::read_into removes even the first allocation: the caller supplies the buffer - a vertex buffer, a memory-mapped region - and the file is decoded straight into it.

Fields§

§metadata: ArrayMetadata

Shape of what was read.

§values: ArrayValues

The values, in the file’s own element type.

Implementations§

Source§

impl ArrayData

Source

pub fn element_count(&self) -> usize

How many elements the shape promises.

Source

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

The block as bytes, borrowed. No copy.

Source

pub fn f64(&self) -> Option<&[f64]>

The values as f64, borrowed, when that is what the file holds.

The path a 3D application takes for coordinates: no conversion, no allocation, just the numbers.

Source

pub fn f32(&self) -> Option<&[f32]>

The values as f32, borrowed, when that is what the file holds.

Source

pub fn i64(&self) -> Option<&[i64]>

The values as i64, borrowed, when that is what the file holds.

Source

pub fn u32(&self) -> Option<&[u32]>

The values as u32, borrowed, when that is what the file holds - what RESQML uses for indices.

Source

pub fn to_f64(&self) -> Vec<f64>

Every element widened to f64.

This copies, and it is the only method here that does. Use ArrayData::f64 when the file already holds doubles, which for coordinates it does.

Trait Implementations§

Source§

impl Clone for ArrayData

Source§

fn clone(&self) -> Self

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 Debug for ArrayData

Source§

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

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

impl PartialEq for ArrayData

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ArrayData

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more