Skip to main content

DataArraySlice

Struct DataArraySlice 

Source
pub struct DataArraySlice<'a> {
    pub start: usize,
    pub end: usize,
    /* private fields */
}
Expand description

Represent a slice of a DataArray that manages offsets and decoding automatically.

This does not copy the data.

Fields§

§start: usize

The start of the slice, in bytes

§end: usize

The end of the slice, in bytes

Implementations§

Source§

impl<'a> DataArraySlice<'a>

Source

pub fn new(source: &'a DataArray, start: usize, end: usize) -> Self

Construct a new DataArraySlice

Source

pub fn decode(&'a self) -> Result<Cow<'a, [u8]>, ArrayRetrievalError>

Decompress and base64-decode encoded bytes, and return the data.

If the data were already decoded, the existing bytes are returned. Otherwise one or more buffers may be allocated to hold the decompressed and decoded bytes.

This is a thin wrapper around DataArray::decoded_slice.

Source

pub const fn is_ion_mobility(&self) -> bool

Test if the the array describes an ion mobility quantity.

§See also

ArrayType::is_ion_mobility

Source

pub fn source(&self) -> &'a DataArray

Get an reference to the source DataArray

Trait Implementations§

Source§

impl<'transient, 'lifespan: 'transient> ByteArrayView<'transient, 'lifespan> for DataArraySlice<'lifespan>

Source§

fn view(&'lifespan self) -> Result<Cow<'lifespan, [u8]>, ArrayRetrievalError>

The core method that exposes the decoded byte array that the type must provide.
Source§

fn dtype(&self) -> BinaryDataArrayType

The real data type encoded in bytes
Source§

fn unit(&self) -> Unit

The unit of measurement each data point is in
Source§

fn name(&self) -> &ArrayType

The kind of array this is
Source§

fn data_processing_reference(&self) -> Option<&str>

Get the identifier referencing a DataProcessing
Source§

fn coerce_from<T: Pod>( buffer: Cow<'transient, [u8]>, ) -> Result<Cow<'transient, [T]>, ArrayRetrievalError>

This is a helper method for the various to_<type> methods like Self::to_f64. It should not need to be called directly. This method relies on bytemuck::try_cast_slice to do the heavy lifting.
Source§

fn coerce<T: Pod>( &'lifespan self, ) -> Result<Cow<'transient, [T]>, ArrayRetrievalError>

This is a helper method for the various to_<type> methods like Self::to_f64. It should not need to be called directly. This calls into Self::coerce_from internally after decoding.
Source§

fn convert<S: Num + Clone + AsPrimitive<D> + Pod, D: Num + Clone + Copy + 'static>( &'lifespan self, ) -> Result<Cow<'transient, [D]>, ArrayRetrievalError>

Decode the array, then copy it to a new array, converting each element from type D to to type S Read more
Source§

fn to_f32( &'lifespan self, ) -> Result<Cow<'transient, [f32]>, ArrayRetrievalError>

Get a view of the data as f32. If the data are stored that way already, no copy is required.
Source§

fn to_f64( &'lifespan self, ) -> Result<Cow<'transient, [f64]>, ArrayRetrievalError>

Get a view of the data as f64. If the data are stored that way already, no copy is required.
Source§

fn to_i32( &'lifespan self, ) -> Result<Cow<'transient, [i32]>, ArrayRetrievalError>

Get a view of the data as i32. If the data are stored that way already, no copy is required.
Source§

fn to_i64( &'lifespan self, ) -> Result<Cow<'transient, [i64]>, ArrayRetrievalError>

Get a view of the data as i64. If the data are stored that way already, no copy is required.
Source§

fn data_len(&'lifespan self) -> Result<usize, ArrayRetrievalError>

The size of encoded array in terms of # of elements of the BinaryDataArrayType given by ByteArrayView::dtype
Source§

fn iter_type<T: Pod>( &'lifespan self, ) -> Result<DataSliceIter<'lifespan, T>, ArrayRetrievalError>

Source§

fn iter_u8( &'lifespan self, ) -> Result<DataSliceIter<'lifespan, u8>, ArrayRetrievalError>

Source§

fn iter_f32( &'lifespan self, ) -> Result<DataSliceIter<'lifespan, f32>, ArrayRetrievalError>

Source§

fn iter_f64( &'lifespan self, ) -> Result<DataSliceIter<'lifespan, f64>, ArrayRetrievalError>

Source§

fn iter_i32( &'lifespan self, ) -> Result<DataSliceIter<'lifespan, i32>, ArrayRetrievalError>

Source§

fn iter_i64( &'lifespan self, ) -> Result<DataSliceIter<'lifespan, i64>, ArrayRetrievalError>

Source§

impl<'a> Clone for DataArraySlice<'a>

Source§

fn clone(&self) -> DataArraySlice<'a>

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<'a> Debug for DataArraySlice<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for DataArraySlice<'a>

§

impl<'a> RefUnwindSafe for DataArraySlice<'a>

§

impl<'a> Send for DataArraySlice<'a>

§

impl<'a> Sync for DataArraySlice<'a>

§

impl<'a> Unpin for DataArraySlice<'a>

§

impl<'a> UnsafeUnpin for DataArraySlice<'a>

§

impl<'a> UnwindSafe for DataArraySlice<'a>

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 = !

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.