pub trait ByteArrayView<'transient, 'lifespan: 'transient> {
Show 19 methods
// Required methods
fn view(
&'lifespan self,
) -> Result<Cow<'lifespan, [u8]>, ArrayRetrievalError>;
fn name(&self) -> &ArrayType;
fn dtype(&self) -> BinaryDataArrayType;
fn unit(&self) -> Unit;
// Provided methods
fn coerce_from<T: Pod>(
buffer: Cow<'transient, [u8]>,
) -> Result<Cow<'transient, [T]>, ArrayRetrievalError> { ... }
fn coerce<T: Pod>(
&'lifespan self,
) -> Result<Cow<'transient, [T]>, ArrayRetrievalError> { ... }
fn convert<S: Num + Clone + AsPrimitive<D> + Pod, D: Num + Clone + Copy + 'static>(
&'lifespan self,
) -> Result<Cow<'transient, [D]>, ArrayRetrievalError> { ... }
fn data_processing_reference(&self) -> Option<&str> { ... }
fn to_f32(
&'lifespan self,
) -> Result<Cow<'transient, [f32]>, ArrayRetrievalError> { ... }
fn to_f64(
&'lifespan self,
) -> Result<Cow<'transient, [f64]>, ArrayRetrievalError> { ... }
fn to_i32(
&'lifespan self,
) -> Result<Cow<'transient, [i32]>, ArrayRetrievalError> { ... }
fn to_i64(
&'lifespan self,
) -> Result<Cow<'transient, [i64]>, ArrayRetrievalError> { ... }
fn data_len(&'lifespan self) -> Result<usize, ArrayRetrievalError> { ... }
fn 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> { ... }
}Expand description
A byte array that may be encoded and compressed as [BinaryCompressionType], or unpacked in
memory and re-interpreted as native types appropriate to BinaryDataArrayType.
The raw bytes must be made available through the ByteArrayView::view method,
but all other behavior is added on top of that
Required Methods§
Sourcefn 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.
Sourcefn dtype(&self) -> BinaryDataArrayType
fn dtype(&self) -> BinaryDataArrayType
The real data type encoded in bytes
Provided Methods§
Sourcefn 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.
Sourcefn 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.
Sourcefn 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
This makes a copy of the data, forcibly coercing the values using AsPrimitive
Sourcefn data_processing_reference(&self) -> Option<&str>
fn data_processing_reference(&self) -> Option<&str>
Get the identifier referencing a DataProcessing
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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::dtype
fn 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>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".