CodeSampleX

Sample

zerocopy 0.8.56: zerocopy::Immutable

Verified sample for cargo zerocopy 0.8.56: zerocopy::Immutable. The contract ran on rust 1 · linux alpine/x64 · docker and passed.

sha256:2f805fdf8f2afd73e53084e6a1467592014b01dde97105782e1b271cecf08636

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment linux · alpine · musl x64 cargo

Verification-run environments

Environment Contract Stages Run
rust 1 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · cargo@1rust:1-alpine@sha256:a10e64dd139b…
2026-09-20

Case

HOW
Goal
verify zerocopy::Immutable in pkg:cargo/zerocopy@0.8.56
Packages
Symbols
  • zerocopy::Immutable
Created
2026-09-20T09:33:48Z

Contract

  1. zerocopy::Immutable is implemented for core primitive scalar types free of interior mutability
  2. zerocopy::Immutable is implemented for arrays and tuples of Immutable elements
  3. zerocopy::Immutable derive macro derives Immutable for structs with Immutable fields
  4. zerocopy::Immutable derive macro derives Immutable for enums with Immutable variants
  5. zerocopy::Unalign wraps an Immutable type and preserves the Immutable contract

Files

  • Cargo.lock
  • Cargo.toml
  • PROMPT.md
  • csx.json
  • spec.json
  • src/lib.rs
  • test/contract.rs

Download the source artifact (tar.gz)

Source

Cargo.lock
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4

[[package]]
name = "proc-macro2"
version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
dependencies = [
 "unicode-ident",
]

[[package]]
name = "quote"
version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
dependencies = [
 "proc-macro2",
]

[[package]]
name = "sample-zerocopy"
version = "1.0.0"
dependencies = [
 "zerocopy",
]

[[package]]
name = "syn"
version = "2.0.119"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
dependencies = [
 "proc-macro2",
 "quote",
 "unicode-ident",
]

[[package]]
name = "unicode-ident"
version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"

[[package]]
name = "zerocopy"
version = "0.8.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "556764e583adb45a9f8d413c2a147fa7e8d821e48e12b14fd560b607998b75eb"
dependencies = [
 "zerocopy-derive",
]

[[package]]
name = "zerocopy-derive"
version = "0.8.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2ab42fc20575779bd240faa45f94a74256f755c0fa9e89f0ede20d91d0cdfc1"
dependencies = [
 "proc-macro2",
 "quote",
 "syn",
]
Cargo.toml
[package]
name = "sample-zerocopy"
version = "1.0.0"
edition = "2021"
publish = false

[dependencies]
zerocopy = { version = "=0.8.56", features = ["derive"] }

[[bin]]
name = "contract"
path = "test/contract.rs"
PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify zerocopy::Immutable in pkg:cargo/zerocopy@0.8.56
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/zerocopy@0.8.56
Demonstrate these symbols/APIs:
  - zerocopy::Immutable

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:f79979c421e9e75343f0cc13bdc8e92919805d91fc99ed5d66722da1f6a6adf1","contract":["zerocopy::Immutable is implemented for core primitive scalar types free of interior mutability","zerocopy::Immutable is implemented for arrays and tuples of Immutable elements","zerocopy::Immutable derive macro derives Immutable for structs with Immutable fields","zerocopy::Immutable derive macro derives Immutable for enums with Immutable variants","zerocopy::Unalign wraps an Immutable type and preserves the Immutable contract"],"goal":"verify zerocopy::Immutable in pkg:cargo/zerocopy@0.8.56","kind":"HOW","packages":["pkg:cargo/zerocopy@0.8.56"],"schemaVersion":1,"symbols":["zerocopy::Immutable"]},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","distro":"alpine","ecosystem":"cargo","libc":"musl","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/zerocopy@0.8.56"],"schemaVersion":1,"subject":"pkg:cargo/zerocopy@0.8.56","symbols":["zerocopy::Immutable"],"verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify zerocopy::Immutable in pkg:cargo/zerocopy@0.8.56",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/zerocopy@0.8.56"
  ],
  "symbols": [
    "zerocopy::Immutable"
  ]
}
src/lib.rs
//! Clean-room verification sample for zerocopy::Immutable.

pub use zerocopy::Immutable;
test/contract.rs
use zerocopy::{Immutable, Unalign};

// Static assertion helper ensuring T implements Immutable
fn assert_immutable<T: ?Sized + Immutable>() {}

// 1. Primitive types
fn test_primitive_immutable() {
    assert_immutable::<u8>();
    assert_immutable::<u16>();
    assert_immutable::<u32>();
    assert_immutable::<u64>();
    assert_immutable::<u128>();
    assert_immutable::<usize>();
    assert_immutable::<i8>();
    assert_immutable::<i16>();
    assert_immutable::<i32>();
    assert_immutable::<i64>();
    assert_immutable::<i128>();
    assert_immutable::<isize>();
    assert_immutable::<bool>();
    assert_immutable::<char>();
    assert_immutable::<f32>();
    assert_immutable::<f64>();
    assert_immutable::<str>();
}

// 2. Arrays and tuples
fn test_composite_immutable() {
    assert_immutable::<[u8; 16]>();
    assert_immutable::<[u32; 4]>();
    assert_immutable::<[u64]>();
    assert_immutable::<()>();
    assert_immutable::<(u8, u32)>();
    assert_immutable::<(u64, bool, i32)>();
}

// 3. Derived structs
#[derive(Debug, PartialEq, Eq, Immutable)]
struct Header {
    magic: u32,
    version: u16,
    flags: u16,
}

fn test_derived_struct() {
    assert_immutable::<Header>();
    let header = Header {
        magic: 0x12345678,
        version: 1,
        flags: 0,
    };
    assert_eq!(header.magic, 0x12345678);
    assert_eq!(header.version, 1);
    assert_eq!(header.flags, 0);
}

// 4. Derived enums
#[derive(Debug, PartialEq, Eq, Immutable)]
#[repr(u8)]
enum PacketType {
    Data = 1,
    Ack = 2,
    Heartbeat = 3,
}

fn test_derived_enum() {
    assert_immutable::<PacketType>();
    let pkt1 = PacketType::Data;
    let pkt2 = PacketType::Ack;
    let pkt3 = PacketType::Heartbeat;
    assert_eq!(pkt1, PacketType::Data);
    assert_eq!(pkt2, PacketType::Ack);
    assert_eq!(pkt3, PacketType::Heartbeat);
}

// 5. Unalign wrapper
fn test_unalign_wrapper() {
    assert_immutable::<Unalign<u32>>();
    assert_immutable::<Unalign<Header>>();
    let unaligned = Unalign::new(0xdeadbeef_u32);
    assert_eq!(unaligned.get(), 0xdeadbeef_u32);
}

fn main() {
    test_primitive_immutable();
    test_composite_immutable();
    test_derived_struct();
    test_derived_enum();
    test_unalign_wrapper();
    println!("All zerocopy::Immutable contract assertions passed successfully.");
}

Origin Seeder

anonymous