示例
want 0.3.1
已验证示例 — cargo want 0.3.1. contract 在 rust 1 · linux alpine/x64 · docker 上运行并通过: want::new creates a channel pair where Giver initially is neither wanting nor…
sha256:ba70fd71b980be60ede2ec4e74925e542e4cda0a96e3edb712384520935c0eef
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 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-19 |
案例
HOW- 目标
- verify pkg:cargo/want@0.3.1
- 创建时间
- 2026-09-19T03:30:54Z
契约
- want::new creates a channel pair where Giver initially is neither wanting nor canceled
- Taker::want signals interest making Giver::is_wanting true
- Giver::give acknowledges want returning true and resets is_wanting to false
- Taker::cancel marks the channel as canceled making Giver::is_canceled true
- Dropping Taker implicitly cancels the channel making Giver::is_canceled true
- SharedGiver shares wanting and cancellation states and implements Clone
- Giver::poll_want returns Poll::Ready(Ok(())) when wanting and Poll::Ready(Err(_)) when canceled
文件
- 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 = "sample-want"
version = "1.0.0"
dependencies = [
"want",
]
[[package]]
name = "try-lock"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]]
name = "want"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e"
dependencies = [
"try-lock",
]
[package]
name = "sample-want"
version = "1.0.0"
edition = "2021"
publish = false
[dependencies]
want = "=0.3.1"
[[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/want@0.3.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/want@0.3.1
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:fba624fefd7abc33b5313727804c64587ee2d9c35170000ba71b3d58d193df35","contract":["want::new creates a channel pair where Giver initially is neither wanting nor canceled","Taker::want signals interest making Giver::is_wanting true","Giver::give acknowledges want returning true and resets is_wanting to false","Taker::cancel marks the channel as canceled making Giver::is_canceled true","Dropping Taker implicitly cancels the channel making Giver::is_canceled true","SharedGiver shares wanting and cancellation states and implements Clone","Giver::poll_want returns Poll::Ready(Ok(())) when wanting and Poll::Ready(Err(_)) when canceled"],"goal":"verify pkg:cargo/want@0.3.1","kind":"HOW","packages":["pkg:cargo/want@0.3.1"],"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/want@0.3.1"],"schemaVersion":1,"subject":"pkg:cargo/want@0.3.1","verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify pkg:cargo/want@0.3.1",
"kind": "HOW",
"packages": [
"pkg:cargo/want@0.3.1"
]
}
//! Clean-room verification sample for want.
pub use want::*;
use std::task::{Context, Poll, Waker};
use want::{new, SharedGiver};
fn main() {
// 1. want::new creates a channel pair where Giver initially is neither wanting nor canceled
let (gv, mut tk) = new();
assert!(!gv.is_wanting(), "initial is_wanting should be false");
assert!(!gv.is_canceled(), "initial is_canceled should be false");
// 2. Taker::want signals interest making Giver::is_wanting true
tk.want();
assert!(gv.is_wanting(), "is_wanting should be true after tk.want()");
assert!(!gv.is_canceled(), "is_canceled should remain false after tk.want()");
// 3. Giver::give acknowledges want returning true and resets is_wanting to false
assert!(gv.give(), "give should return true when wanting");
assert!(!gv.is_wanting(), "is_wanting should be false after give");
assert!(!gv.give(), "give should return false when already idle");
// 4. Taker::cancel marks the channel as canceled making Giver::is_canceled true
let (gv2, mut tk2) = new();
assert!(!gv2.is_canceled());
tk2.cancel();
assert!(gv2.is_canceled(), "is_canceled should be true after tk.cancel()");
// 5. Dropping Taker implicitly cancels the channel making Giver::is_canceled true
let (gv3, tk3) = new();
assert!(!gv3.is_canceled());
drop(tk3);
assert!(gv3.is_canceled(), "is_canceled should be true after dropping Taker");
// 6. SharedGiver shares wanting and cancellation states and implements Clone
let (gv4, mut tk4) = new();
let shared: SharedGiver = gv4.shared();
let shared_clone = shared.clone();
assert!(!shared.is_wanting());
assert!(!shared.is_canceled());
assert!(!shared_clone.is_wanting());
assert!(!shared_clone.is_canceled());
tk4.want();
assert!(shared.is_wanting());
assert!(shared_clone.is_wanting());
tk4.cancel();
assert!(shared.is_canceled());
assert!(shared_clone.is_canceled());
// 7. Giver::poll_want returns Poll::Ready(Ok(())) when wanting and Poll::Ready(Err(_)) when canceled
let waker = Waker::noop();
let mut cx = Context::from_waker(&waker);
let (mut gv5, mut tk5) = new();
// Initially not wanting, so poll_want would park (returns Poll::Pending)
assert!(matches!(gv5.poll_want(&mut cx), Poll::Pending));
// When wanting, returns Poll::Ready(Ok(()))
tk5.want();
assert!(matches!(gv5.poll_want(&mut cx), Poll::Ready(Ok(()))));
// When canceled, returns Poll::Ready(Err(_))
let (mut gv6, mut tk6) = new();
tk6.cancel();
assert!(matches!(gv6.poll_want(&mut cx), Poll::Ready(Err(_))));
println!("All want contract assertions passed successfully.");
}
原始种子者
匿名