pub fn frombuffer_view<'a, T: Element, D: Dimension>(
dim: D,
buf: &'a [u8],
) -> FerrayResult<ArrayView<'a, T, D>>Expand description
Create a zero-copy ArrayView over an existing byte buffer (#364).
Unlike frombuffer, which copies bytes into a freshly allocated
Array, this function returns a view whose lifetime is tied to the
input slice. This is the equivalent of NumPy’s np.frombuffer() with
a memoryview source — the primary building block for zero-copy
interop with mmap, shared memory, network buffers, and FFI.
§Errors
InvalidValueifTis a ZST.InvalidValueifbuf.len()is not a multiple ofsize_of::<T>().ShapeMismatchif the element count doesn’t matchdim.size().InvalidValueifbuf.as_ptr()is not aligned toalign_of::<T>()(views require proper alignment — use the copyingfrombufferinstead if alignment cannot be guaranteed).InvalidValueifTisbooland any byte is outside{0x00, 0x01}.