示例
serde_derive 1.0.229
已验证示例 — cargo serde_derive 1.0.229. contract 在 rust 1 · linux alpine/x64 · docker 上运行并通过: #[derive(Serialize, Deserialize)] serializes and deserializes…
sha256:84042027cfd19f67c2637017ddf24a6299e86e9f6918da48f1544aa3a43dd81c
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
linux · alpine · musl x64 cargo
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| 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-14 |
案例
HOW- 目标
- verify pkg:cargo/serde_derive@1.0.229
- 创建时间
- 2026-09-14T20:59:56Z
契约
- #[derive(Serialize, Deserialize)] serializes and deserializes structs with named fields
- serde field attributes rename, default, and skip alter struct field serialization and deserialization
- serde container attributes rename_all and deny_unknown_fields govern struct field mapping and validation
- #[derive(Serialize, Deserialize)] serializes and deserializes enums with unit, tuple, and struct variants
文件
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- test/contract.rs
源代码
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "itoa"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
[[package]]
name = "memchr"
version = "2.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
[[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-serde-derive"
version = "1.0.0"
dependencies = [
"serde",
"serde_derive",
"serde_json",
]
[[package]]
name = "serde"
version = "1.0.229"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
dependencies = [
"serde_core",
]
[[package]]
name = "serde_core"
version = "1.0.229"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.229"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.151"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14"
dependencies = [
"itoa",
"memchr",
"serde",
"serde_core",
"zmij",
]
[[package]]
name = "syn"
version = "3.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12df2e0110f65b775f769bb17ef989067a1d931b2eb822bd4346631eeada89f9"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[[package]]
name = "zmij"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
[package]
name = "sample-serde-derive"
version = "1.0.0"
edition = "2021"
publish = false
[dependencies]
serde_derive = "=1.0.229"
serde = "=1.0.229"
serde_json = "=1.0.151"
[[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 pkg:cargo/serde_derive@1.0.229
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/serde_derive@1.0.229
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:b1b7ecb9f3967cb896ec068941dfda5b34ba163b3b0edface3803fd426bc620d","contract":["#[derive(Serialize, Deserialize)] serializes and deserializes structs with named fields","serde field attributes rename, default, and skip alter struct field serialization and deserialization","serde container attributes rename_all and deny_unknown_fields govern struct field mapping and validation","#[derive(Serialize, Deserialize)] serializes and deserializes enums with unit, tuple, and struct variants"],"goal":"verify pkg:cargo/serde_derive@1.0.229","kind":"HOW","packages":["pkg:cargo/serde_derive@1.0.229"],"schemaVersion":1},"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/serde_derive@1.0.229"],"schemaVersion":1,"subject":"pkg:cargo/serde_derive@1.0.229","verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify pkg:cargo/serde_derive@1.0.229",
"kind": "HOW",
"packages": [
"pkg:cargo/serde_derive@1.0.229"
]
}
//! Clean-room verification sample for serde_derive.
pub use serde_derive::*;
use serde_derive::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, PartialEq)]
struct User {
id: u64,
name: String,
active: bool,
}
fn default_port() -> u16 {
8080
}
#[derive(Serialize, Deserialize, Debug, PartialEq)]
struct FieldConfig {
#[serde(rename = "config_id")]
id: u32,
#[serde(default = "default_port")]
port: u16,
#[serde(skip)]
internal_flag: bool,
}
#[derive(Serialize, Deserialize, Debug, PartialEq)]
#[serde(rename_all = "kebab-case", deny_unknown_fields)]
struct ServerSettings {
host_name: String,
max_conns: usize,
}
#[derive(Serialize, Deserialize, Debug, PartialEq)]
enum Action {
Quit,
Move { x: i32, y: i32 },
Write(String),
}
fn main() {
// 1. #[derive(Serialize, Deserialize)] serializes and deserializes structs with named fields
let user = User {
id: 1001,
name: "test_user".to_string(),
active: true,
};
let user_json = serde_json::to_string(&user).expect("serialize User");
assert_eq!(user_json, r#"{"id":1001,"name":"test_user","active":true}"#);
let user_de: User = serde_json::from_str(&user_json).expect("deserialize User");
assert_eq!(user, user_de);
// 2. serde field attributes rename, default, and skip alter struct field serialization and deserialization
let config = FieldConfig {
id: 42,
port: 9000,
internal_flag: true,
};
let config_json = serde_json::to_string(&config).expect("serialize FieldConfig");
assert_eq!(config_json, r#"{"config_id":42,"port":9000}"#);
let config_de: FieldConfig =
serde_json::from_str(r#"{"config_id":42}"#).expect("deserialize FieldConfig with default");
assert_eq!(config_de.id, 42);
assert_eq!(config_de.port, 8080);
assert!(!config_de.internal_flag);
// 3. serde container attributes rename_all and deny_unknown_fields govern struct field mapping and validation
let settings = ServerSettings {
host_name: "127.0.0.1".to_string(),
max_conns: 128,
};
let settings_json = serde_json::to_string(&settings).expect("serialize ServerSettings");
assert_eq!(settings_json, r#"{"host-name":"127.0.0.1","max-conns":128}"#);
let settings_de: ServerSettings =
serde_json::from_str(&settings_json).expect("deserialize ServerSettings");
assert_eq!(settings, settings_de);
let unknown_field_res: Result<ServerSettings, _> =
serde_json::from_str(r#"{"host-name":"127.0.0.1","max-conns":128,"unexpected":true}"#);
assert!(
unknown_field_res.is_err(),
"deny_unknown_fields must reject unexpected fields"
);
// 4. #[derive(Serialize, Deserialize)] serializes and deserializes enums with unit, tuple, and struct variants
let quit = Action::Quit;
let quit_json = serde_json::to_string(&quit).expect("serialize Action::Quit");
assert_eq!(quit_json, r#""Quit""#);
let quit_de: Action = serde_json::from_str(&quit_json).expect("deserialize Action::Quit");
assert_eq!(quit, quit_de);
let mv = Action::Move { x: 10, y: -5 };
let mv_json = serde_json::to_string(&mv).expect("serialize Action::Move");
assert_eq!(mv_json, r#"{"Move":{"x":10,"y":-5}}"#);
let mv_de: Action = serde_json::from_str(&mv_json).expect("deserialize Action::Move");
assert_eq!(mv, mv_de);
let write = Action::Write("payload".to_string());
let write_json = serde_json::to_string(&write).expect("serialize Action::Write");
assert_eq!(write_json, r#"{"Write":"payload"}"#);
let write_de: Action = serde_json::from_str(&write_json).expect("deserialize Action::Write");
assert_eq!(write, write_de);
println!("All serde_derive contract assertions passed successfully.");
}
原始种子者
匿名