Exemple
percent-encoding 2.3.2: percent_encoding::percent_decode, percent_encoding::percent_encode
Échantillon vérifié pour cargo percent-encoding 2.3.2: percent_encoding::percent_decode, percent_encoding::percent_encode. Le contrat s'est exécuté sur rust…
sha256:9fd6a8af4c9b6bac66aad74639b093739bc4830c5911bc5116ca50faefae81b4
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux · alpine · musl x64 cargo
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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 |
Cas
HOW- Objectif
- verify pkg:cargo/percent-encoding@2.3.2
- Paquets
- Symboles
-
- percent_encoding::percent_decode
- percent_encoding::percent_encode
- Créé
- 2026-09-18T05:46:03Z
Contrat
- percent_encode encodes reserved bytes using AsciiSet
- percent_encode with NON_ALPHANUMERIC encodes symbols and whitespace
- percent_decode decodes valid percent-encoded byte sequences
- percent_decode_str decodes percent-encoded string slice into UTF-8
- percent_decode preserves invalid percent sequences verbatim
- percent_encode_byte returns exact two-digit hex representation
Fichiers
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- test/contract.rs
Code source
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "percent-encoding"
version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
[[package]]
name = "sample-percent-encoding"
version = "1.0.0"
dependencies = [
"percent-encoding",
]
[package]
name = "sample-percent-encoding"
version = "1.0.0"
edition = "2021"
publish = false
[dependencies]
percent-encoding = "=2.3.2"
[[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/percent-encoding@2.3.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/percent-encoding@2.3.2
Demonstrate these symbols/APIs:
- percent_encoding::percent_decode
- percent_encoding::percent_encode
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:1424073247a992001bcb6152a5b193d8cf108aa34b99388a138156dd0e37fb55","contract":["percent_encode encodes reserved bytes using AsciiSet","percent_encode with NON_ALPHANUMERIC encodes symbols and whitespace","percent_decode decodes valid percent-encoded byte sequences","percent_decode_str decodes percent-encoded string slice into UTF-8","percent_decode preserves invalid percent sequences verbatim","percent_encode_byte returns exact two-digit hex representation"],"goal":"verify pkg:cargo/percent-encoding@2.3.2","kind":"HOW","packages":["pkg:cargo/percent-encoding@2.3.2"],"schemaVersion":1,"symbols":["percent_encoding::percent_decode","percent_encoding::percent_encode"]},"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/percent-encoding@2.3.2"],"schemaVersion":1,"subject":"pkg:cargo/percent-encoding@2.3.2","symbols":["percent_encoding::percent_decode","percent_encoding::percent_encode"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify pkg:cargo/percent-encoding@2.3.2",
"kind": "HOW",
"packages": [
"pkg:cargo/percent-encoding@2.3.2"
],
"symbols": [
"percent_encoding::percent_decode",
"percent_encoding::percent_encode"
]
}
//! Clean-room verification sample for percent-encoding.
pub use percent_encoding::*;
use percent_encoding::{
percent_decode, percent_decode_str, percent_encode, percent_encode_byte, utf8_percent_encode,
AsciiSet, CONTROLS, NON_ALPHANUMERIC,
};
use std::borrow::Cow;
/// Custom fragment percent-encode set
const FRAGMENT: &AsciiSet = &CONTROLS.add(b' ').add(b'"').add(b'<').add(b'>').add(b'`');
fn main() {
// 1. percent_encode encodes reserved bytes using AsciiSet
let input = b"foo <bar> \"baz\"";
let encoded = percent_encode(input, FRAGMENT).to_string();
assert_eq!(encoded, "foo%20%3Cbar%3E%20%22baz%22");
let utf8_encoded = utf8_percent_encode("hello world", FRAGMENT).to_string();
assert_eq!(utf8_encoded, "hello%20world");
// 2. percent_encode with NON_ALPHANUMERIC encodes symbols and whitespace
let input2 = b"Hello, World! 123";
let encoded2 = percent_encode(input2, NON_ALPHANUMERIC).to_string();
assert_eq!(encoded2, "Hello%2C%20World%21%20123");
// 3. percent_decode decodes valid percent-encoded byte sequences
let encoded_bytes = b"Hello%20World%21";
let decoded_bytes: Vec<u8> = percent_decode(encoded_bytes).collect();
assert_eq!(decoded_bytes, b"Hello World!");
let decoded_cow: Cow<str> = percent_decode(encoded_bytes).decode_utf8().unwrap();
assert_eq!(decoded_cow, "Hello World!");
// 4. percent_decode_str decodes percent-encoded string slice into UTF-8
let decoded_str = percent_decode_str("foo%2Fbar%3Fkey%3Dvalue").decode_utf8().unwrap();
assert_eq!(decoded_str, "foo/bar?key=value");
// 5. percent_decode preserves invalid percent sequences verbatim
let invalid = b"%zz%2%ag%";
let decoded_invalid = percent_decode(invalid).decode_utf8_lossy();
assert_eq!(decoded_invalid, "%zz%2%ag%");
// 6. percent_encode_byte returns exact two-digit hex representation
assert_eq!(percent_encode_byte(b' '), "%20");
assert_eq!(percent_encode_byte(b'/'), "%2F");
assert_eq!(percent_encode_byte(0x00), "%00");
assert_eq!(percent_encode_byte(0xFF), "%FF");
println!("All percent-encoding contract assertions passed successfully.");
}
Seeder d'origine
anonyme