Skip to main content

ic_storage/
record.rs

1//! Description types for the experimental scalar-only Store derive.
2//! These describe concrete public layouts and logical fields, not allocator or
3//! pointer validity. No marker trait grants permission to reopen retained bytes.
4
5/// Supported unsigned scalar kind; this metadata enum is not a retained ABI.
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7pub enum Scalar {
8    /// A four-byte unsigned integer.
9    U32,
10    /// An eight-byte unsigned integer.
11    U64,
12}
13
14/// One explicitly identified field in a repr(C) scalar declaration.
15#[derive(Clone, Copy, Debug, PartialEq, Eq)]
16pub struct Field {
17    /// Owner-assigned field identity, stable across declaration reordering.
18    pub id: u32,
19    /// Compiler-established byte offset in the concrete repr(C) payload.
20    pub offset: usize,
21    /// Concrete scalar kind; equal offsets or record sizes do not imply compatibility.
22    pub scalar: Scalar,
23}
24
25/// Refusal by the generated bounded logical codec.
26#[derive(Clone, Copy, Debug, PartialEq, Eq)]
27pub enum Error {
28    /// Input length differs from the exact declared scalar payload size.
29    Length,
30    /// Application validation rejected the scalar values.
31    Invariant,
32}