Sample
zerocopy-derive 0.8.56: zerocopy_derive
Verified sample for cargo zerocopy-derive 0.8.56: zerocopy_derive. The contract ran on rust 1 · linux alpine/x64 · docker and passed.
sha256:ffe57bef8864ff346bca6799deeb675585ea5cb8d50cabe78794f30a6f16535c
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_derive in pkg:cargo/zerocopy-derive@0.8.56
- Packages
- Symbols
-
- zerocopy_derive
- Created
- 2026-09-20T11:44:03Z
Contract
- zerocopy_derive FromBytes and IntoBytes derive zero-copy byte parsing and serialization for C-repr structs
- zerocopy_derive Unaligned derives 1-byte alignment allowance for types containing only unaligned fields
- zerocopy_derive FromZeros derives safe initialization from all-zero byte patterns
- zerocopy_derive TryFromBytes derives fallible conversion validating bit validity invariants
- zerocopy_derive derives work on tuple structs and unit structs
Files
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- test/contract.rs
Source
# 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-derive"
version = "1.0.0"
dependencies = [
"zerocopy",
"zerocopy-derive",
]
[[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",
]
[package]
name = "sample-zerocopy-derive"
version = "1.0.0"
edition = "2021"
publish = false
[dependencies]
zerocopy-derive = "=0.8.56"
zerocopy = "=0.8.56"
[[bin]]
name = "contract"
path = "test/contract.rs"
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_derive in pkg:cargo/zerocopy-derive@0.8.56
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/zerocopy-derive@0.8.56
Demonstrate these symbols/APIs:
- zerocopy_derive
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.
{"case":{"caseId":"case:sha256:e6628aff3459993cc023456a496f0cac415a99567adcb6b24e96173d6b760a19","contract":["zerocopy_derive FromBytes and IntoBytes derive zero-copy byte parsing and serialization for C-repr structs","zerocopy_derive Unaligned derives 1-byte alignment allowance for types containing only unaligned fields","zerocopy_derive FromZeros derives safe initialization from all-zero byte patterns","zerocopy_derive TryFromBytes derives fallible conversion validating bit validity invariants","zerocopy_derive derives work on tuple structs and unit structs"],"goal":"verify zerocopy_derive in pkg:cargo/zerocopy-derive@0.8.56","kind":"HOW","packages":["pkg:cargo/zerocopy-derive@0.8.56"],"schemaVersion":1,"symbols":["zerocopy_derive"]},"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-derive@0.8.56"],"schemaVersion":1,"subject":"pkg:cargo/zerocopy-derive@0.8.56","symbols":["zerocopy_derive"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify zerocopy_derive in pkg:cargo/zerocopy-derive@0.8.56",
"kind": "HOW",
"packages": [
"pkg:cargo/zerocopy-derive@0.8.56"
],
"symbols": [
"zerocopy_derive"
]
}
//! Clean-room verification sample for zerocopy-derive.
pub use zerocopy_derive::*;
use zerocopy_derive::{FromBytes, FromZeros, Immutable, IntoBytes, KnownLayout, TryFromBytes, Unaligned};
use zerocopy::{FromBytes, FromZeros, IntoBytes, TryFromBytes};
// 1. FromBytes and IntoBytes derive zero-copy byte parsing and serialization for C-repr structs
#[derive(FromBytes, IntoBytes, KnownLayout, Immutable, Debug, PartialEq, Eq, Clone, Copy)]
#[repr(C)]
struct Header {
tag: [u8; 4],
code: u16,
flags: u16,
}
// 2. Unaligned derives 1-byte alignment allowance for types containing only unaligned fields
#[derive(FromBytes, IntoBytes, KnownLayout, Immutable, Unaligned, Debug, PartialEq, Eq, Clone, Copy)]
#[repr(C)]
struct Packet {
id: u8,
payload: [u8; 7],
}
// 3. FromZeros derives safe initialization from all-zero byte patterns
#[derive(FromZeros, KnownLayout, Immutable, Debug, PartialEq, Eq)]
#[repr(C)]
struct ZeroInit {
a: u32,
b: u64,
}
// 4. TryFromBytes derives fallible conversion validating bit validity invariants
#[derive(TryFromBytes, KnownLayout, Immutable, Debug, PartialEq, Eq, Clone, Copy)]
#[repr(u8)]
#[allow(dead_code)]
enum Status {
Idle = 0,
Active = 1,
Finished = 2,
}
// 5. Tuple structs with zerocopy_derive derive macros
#[derive(FromBytes, IntoBytes, KnownLayout, Immutable, Unaligned, Debug, PartialEq, Eq, Clone, Copy)]
#[repr(C)]
struct ColorRgb(u8, u8, u8);
fn main() {
// 1. FromBytes and IntoBytes
let h = Header {
tag: *b"TEST",
code: 0x1234,
flags: 0x5678,
};
let bytes = h.as_bytes();
assert_eq!(bytes.len(), 8);
let parsed = Header::read_from_bytes(bytes).unwrap();
assert_eq!(parsed, h);
// 2. Unaligned
let raw = [42u8, 1, 2, 3, 4, 5, 6, 7];
let pkt = Packet::read_from_bytes(&raw[..]).unwrap();
assert_eq!(pkt.id, 42);
assert_eq!(pkt.payload, [1, 2, 3, 4, 5, 6, 7]);
assert_eq!(core::mem::align_of::<Packet>(), 1);
// 3. FromZeros
let z: ZeroInit = ZeroInit::new_zeroed();
assert_eq!(z.a, 0);
assert_eq!(z.b, 0);
// 4. TryFromBytes
let valid_status = Status::try_read_from_bytes(&[1u8]).unwrap();
assert_eq!(valid_status, Status::Active);
let invalid_status = Status::try_read_from_bytes(&[99u8]);
assert!(invalid_status.is_err());
// 5. Tuple struct
let rgb = ColorRgb(255, 128, 0);
assert_eq!(rgb.as_bytes(), &[255, 128, 0]);
let parsed_rgb = ColorRgb::read_from_bytes(&[255, 128, 0]).unwrap();
assert_eq!(parsed_rgb, rgb);
println!("All zerocopy_derive contract assertions passed successfully.");
}
Origin Seeder
anonymous