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: usizeThe start of the slice, in bytes
end: usizeThe end of the slice, in bytes
Implementations§
Source§impl<'a> DataArraySlice<'a>
impl<'a> DataArraySlice<'a>
Sourcepub fn new(source: &'a DataArray, start: usize, end: usize) -> Self
pub fn new(source: &'a DataArray, start: usize, end: usize) -> Self
Construct a new DataArraySlice
Sourcepub fn decode(&'a self) -> Result<Cow<'a, [u8]>, ArrayRetrievalError>
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.
Sourcepub const fn is_ion_mobility(&self) -> bool
pub const fn is_ion_mobility(&self) -> bool
Trait Implementations§
Source§impl<'transient, 'lifespan: 'transient> ByteArrayView<'transient, 'lifespan> for DataArraySlice<'lifespan>
impl<'transient, 'lifespan: 'transient> ByteArrayView<'transient, 'lifespan> for DataArraySlice<'lifespan>
Source§fn view(&'lifespan self) -> Result<Cow<'lifespan, [u8]>, ArrayRetrievalError>
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
fn dtype(&self) -> BinaryDataArrayType
The real data type encoded in bytes
Source§fn data_processing_reference(&self) -> Option<&str>
fn data_processing_reference(&self) -> Option<&str>
Get the identifier referencing a
DataProcessingSource§fn coerce_from<T: Pod>(
buffer: Cow<'transient, [u8]>,
) -> Result<Cow<'transient, [T]>, ArrayRetrievalError>
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>
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>
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 moreSource§fn to_f32(
&'lifespan self,
) -> Result<Cow<'transient, [f32]>, ArrayRetrievalError>
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>
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>
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>
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>
fn data_len(&'lifespan self) -> Result<usize, ArrayRetrievalError>
The size of encoded array in terms of # of elements of the
BinaryDataArrayType given by ByteArrayView::dtypefn iter_type<T: Pod>( &'lifespan self, ) -> Result<DataSliceIter<'lifespan, T>, ArrayRetrievalError>
fn iter_u8( &'lifespan self, ) -> Result<DataSliceIter<'lifespan, u8>, ArrayRetrievalError>
fn iter_f32( &'lifespan self, ) -> Result<DataSliceIter<'lifespan, f32>, ArrayRetrievalError>
fn iter_f64( &'lifespan self, ) -> Result<DataSliceIter<'lifespan, f64>, ArrayRetrievalError>
fn iter_i32( &'lifespan self, ) -> Result<DataSliceIter<'lifespan, i32>, ArrayRetrievalError>
fn iter_i64( &'lifespan self, ) -> Result<DataSliceIter<'lifespan, i64>, ArrayRetrievalError>
Source§impl<'a> Clone for DataArraySlice<'a>
impl<'a> Clone for DataArraySlice<'a>
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> 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