Skip to main content

ariadnetor_tensor/
storage.rs

1//! Storage abstraction: pure-data tensor element container.
2//!
3//! `Storage` is the data-only half of the tensor split. It exposes only
4//! what is needed to validate buffer length against a [`TensorLayout`]
5//! and to access the element scalar type. Interpretation metadata
6//! (shape, memory order, symmetry sector) lives on the paired
7//! [`TensorLayout`](crate::TensorLayout), not here.
8
9/// Pure-data tensor element container.
10///
11/// Implementors expose a flat element count and the scalar element
12/// type. They are intentionally unaware of shape, memory order, and
13/// symmetry sector — those properties live on the paired
14/// [`TensorLayout`](crate::TensorLayout). The
15/// [`StorageFor<L>`](crate::StorageFor) marker trait declares which
16/// `Storage` types are valid partners for a given layout.
17pub trait Storage {
18    /// Scalar element type stored in this container.
19    type Element;
20
21    /// Number of element slots actually held by the storage buffer.
22    ///
23    /// For [`TensorData`](crate::TensorData) construction, this is
24    /// compared against [`TensorLayout::storage_extent`](crate::TensorLayout::storage_extent)
25    /// to detect storage-layout boundary violations.
26    fn flat_len(&self) -> usize;
27}