1use core::fmt::Display;
2
3use crate::TypeHash;
4
5use crate::{OperationReflect, Value};
6
7#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9#[derive(Debug, Clone, TypeHash, PartialEq, Eq, Hash, OperationReflect)]
10#[operation(opcode_name = MetadataOpCode, pure)]
11#[allow(missing_docs)]
12pub enum Metadata {
13 Stride {
15 dim: Value,
16 #[args(allow_ptr)]
17 list: Value,
18 },
19 Shape {
21 dim: Value,
22 #[args(allow_ptr)]
23 list: Value,
24 },
25 BufferLength {
27 #[args(allow_ptr)]
28 list: Value,
29 },
30}
31
32impl Display for Metadata {
33 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
34 match self {
35 Metadata::Stride { dim, list } => write!(f, "{list}.strides[{dim}]"),
36 Metadata::Shape { dim, list } => write!(f, "{list}.shape[{dim}]"),
37 Metadata::BufferLength { list } => write!(f, "buffer_len({list})"),
38 }
39 }
40}