pub trait ViewElement: Sized {
// Required method
fn bytes_as_slice<'a>(
bytes: &'a [u8],
type_desc: &PyValue,
len: usize,
) -> Result<&'a [Self], ViewDataError>;
}Expand description
An array element type that can be viewed (without copying) in an .npy
file.
Required Methods§
Sourcefn bytes_as_slice<'a>(
bytes: &'a [u8],
type_desc: &PyValue,
len: usize,
) -> Result<&'a [Self], ViewDataError>
fn bytes_as_slice<'a>( bytes: &'a [u8], type_desc: &PyValue, len: usize, ) -> Result<&'a [Self], ViewDataError>
Casts bytes into a slice of elements of length len.
Returns Err(_) in at least the following cases:
- if the
type_descdoes not matchSelfwith native endianness - if the
bytesslice is misaligned for elements of typeSelf - if the
bytesslice is too short forlenelements - if the
bytesslice has extra bytes afterlenelements
May panic if len * size_of::<Self>() overflows.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl ViewElement for Complex<f32>
Available on crate feature num-complex-0_4 only.
impl ViewElement for Complex<f32>
Available on crate feature
num-complex-0_4 only.fn bytes_as_slice<'a>( bytes: &'a [u8], type_desc: &Value, len: usize, ) -> Result<&'a [Self], ViewDataError>
Source§impl ViewElement for Complex<f64>
Available on crate feature num-complex-0_4 only.
impl ViewElement for Complex<f64>
Available on crate feature
num-complex-0_4 only.