Пример
digest 0.10.7: Update
Проверенный пример — cargo digest 0.10.7: Update. Контракт выполнен на rust 1 · linux alpine/x64 · docker и пройден: Update::update(&mut self, data: &[u8])…
sha256:2f5f500321caff42ee248b319e0e5c76d537856e5b84aef76491e3569fd476e0
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
linux 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-11-04 |
Кейс
HOW- Цель
- verify Update in pkg:cargo/digest@0.10.7
- Пакеты
- Символы
-
- Update
- Создан
- 2026-11-04T02:21:20Z
Контракт
- Update::update(&mut self, data: &[u8]) appends successive byte slices in call order, and an empty slice &[u8] leaves accumulated state unchanged
- Update::chain(self, data: impl AsRef<[u8]>) -> Self consumes self, invokes update(data.as_ref()), and returns the updated value for fluent chaining across &[u8], &str, and Vec<u8>
- Update is object-safe and dispatches update(&[u8]) through &mut dyn Update
Файлы
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- test/contract.rs
Исходный код
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "block-buffer"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
dependencies = [
"generic-array",
]
[[package]]
name = "crypto-common"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
dependencies = [
"generic-array",
"typenum",
]
[[package]]
name = "digest"
version = "0.10.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
dependencies = [
"block-buffer",
"crypto-common",
]
[[package]]
name = "generic-array"
version = "0.14.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
dependencies = [
"typenum",
"version_check",
]
[[package]]
name = "sample"
version = "0.1.0"
dependencies = [
"digest",
]
[[package]]
name = "typenum"
version = "1.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
[[package]]
name = "version_check"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
[package]
name = "sample"
version = "0.1.0"
edition = "2021"
[[bin]]
name = "sample"
path = "test/contract.rs"
[dependencies]
digest = "=0.10.7"
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 Update in pkg:cargo/digest@0.10.7
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/digest@0.10.7
Demonstrate these symbols/APIs:
- Update
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:8e4aa5c3c51a31d0c04cc239bc33d856852ce79c03077d8a60079d99946bde77","contract":["Update::update(\u0026mut self, data: \u0026[u8]) appends successive byte slices in call order, and an empty slice \u0026[u8] leaves accumulated state unchanged","Update::chain(self, data: impl AsRef\u003c[u8]\u003e) -\u003e Self consumes self, invokes update(data.as_ref()), and returns the updated value for fluent chaining across \u0026[u8], \u0026str, and Vec\u003cu8\u003e","Update is object-safe and dispatches update(\u0026[u8]) through \u0026mut dyn Update"],"goal":"verify Update in pkg:cargo/digest@0.10.7","kind":"HOW","packages":["pkg:cargo/digest@0.10.7"],"schemaVersion":1,"symbols":["Update"]},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","ecosystem":"cargo","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/digest@0.10.7"],"schemaVersion":1,"subject":"pkg:cargo/digest@0.10.7","symbols":["Update"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify Update in pkg:cargo/digest@0.10.7",
"kind": "HOW",
"packages": [
"pkg:cargo/digest@0.10.7"
],
"symbols": [
"Update"
]
}
use digest::Update;
#[derive(Default, Debug, PartialEq, Eq)]
struct ByteAccumulator {
buf: Vec<u8>,
}
impl Update for ByteAccumulator {
fn update(&mut self, data: &[u8]) {
self.buf.extend_from_slice(data);
}
}
fn accept_update_dyn(target: &mut dyn Update, chunk: &[u8]) {
target.update(chunk);
}
fn main() {
// 1. Direct Update::update calls accumulate slices in order
let mut acc = ByteAccumulator::default();
acc.update(b"hello");
acc.update(b" ");
acc.update(b"world");
assert_eq!(acc.buf, b"hello world");
// 2. Empty slice update preserves existing state
acc.update(b"");
assert_eq!(acc.buf, b"hello world");
// 3. Update::chain consumes Self, appends AsRef<[u8]> inputs, and returns Self
let chained = ByteAccumulator::default()
.chain(b"alpha")
.chain("-beta")
.chain(vec![b'-', b'1']);
assert_eq!(chained.buf, b"alpha-beta-1");
// 4. Update is object-safe (&mut dyn Update)
let mut dyn_acc = ByteAccumulator::default();
accept_update_dyn(&mut dyn_acc, b"dyn-");
accept_update_dyn(&mut dyn_acc, b"ok");
assert_eq!(dyn_acc.buf, b"dyn-ok");
}
Исходный сидер
аноним