pub struct Schema {
pub dtype: DataType,
pub shape: Option<Vec<Dimension>>,
}Expand description
Describes the shape and type of a Value, without holding the actual data.
Used by:
- Filters: declare what they accept (input) and produce (output)
- Compiler: validate type compatibility between connected filters
- VirtualValue: know schema without materializing
- Cache metadata: describe stored entries
Fields§
§dtype: DataTypeThe primitive data type.
shape: Option<Vec<Dimension>>Shape dimensions. Empty for scalars, [n] for vectors, [r,c] for matrices, etc.
None means shape is dynamic/unknown.
Implementations§
Source§impl Schema
impl Schema
Sourcepub fn vector(dtype: DataType, len: usize) -> Self
pub fn vector(dtype: DataType, len: usize) -> Self
Create a schema for a 1D tensor (vector) of known length.
Sourcepub fn matrix(dtype: DataType, rows: usize, cols: usize) -> Self
pub fn matrix(dtype: DataType, rows: usize, cols: usize) -> Self
Create a schema for a 2D tensor (matrix) with known dimensions.
Sourcepub fn batched(dtype: DataType, feature_dims: &[usize]) -> Self
pub fn batched(dtype: DataType, feature_dims: &[usize]) -> Self
Create a schema for a tensor with a dynamic batch dimension.
Sourcepub fn is_compatible_with(&self, other: &Schema) -> bool
pub fn is_compatible_with(&self, other: &Schema) -> bool
Check if this schema is compatible with another (can be connected in a pipeline).
Compatibility rules:
- Same dtype required (no implicit coercion)
- If both shapes are known, fixed dimensions must match
- Dynamic dimensions are compatible with any size
- Unknown shape (None) is compatible with anything of the same dtype
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Schema
impl<'de> Deserialize<'de> for Schema
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Schema
impl StructuralPartialEq for Schema
Auto Trait Implementations§
impl Freeze for Schema
impl RefUnwindSafe for Schema
impl Send for Schema
impl Sync for Schema
impl Unpin for Schema
impl UnsafeUnpin for Schema
impl UnwindSafe for Schema
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