示例
serde_urlencoded 0.7.1: serde_urlencoded::from_str, serde_urlencoded::to_string
已验证示例 — cargo serde_urlencoded 0.7.1: serde_urlencoded::from_str, serde_urlencoded::to_string. contract 在 rust 1 · linux alpine/x64 · docker 上运行并通过.
sha256:9a34876ce97d62f759ace2d6d3acbe4a6163cc2bb7e048d742f23eb1ace138e9
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 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/serde_urlencoded@0.7.1
- 符号
-
- serde_urlencoded::from_str
- serde_urlencoded::to_string
- 创建时间
- 2026-09-18T13:04:54Z
契约
- to_string serializes sequence of key-value pairs to URL-encoded query string
- to_string percent-encodes special characters and spaces
- from_str deserializes URL-encoded query string into sequence of key-value pairs
- from_str decodes percent-encoded characters and plus signs
- from_str returns error when value cannot be parsed into target type
文件
- 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 = "form_urlencoded"
version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf"
dependencies = [
"percent-encoding",
]
[[package]]
name = "itoa"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
[[package]]
name = "percent-encoding"
version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
[[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 = "ryu"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
[[package]]
name = "sample-serde-urlencoded"
version = "1.0.0"
dependencies = [
"serde_urlencoded",
]
[[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_urlencoded"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"
dependencies = [
"form_urlencoded",
"itoa",
"ryu",
"serde",
]
[[package]]
name = "syn"
version = "3.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8593e8e72159ed2257d083c7a454a85cbf854f37a0966d8d483aff8c8a3ebcee"
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 = "sample-serde-urlencoded"
version = "1.0.0"
edition = "2021"
publish = false
[dependencies]
serde_urlencoded = "=0.7.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/serde_urlencoded@0.7.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/serde_urlencoded@0.7.1
Demonstrate these symbols/APIs:
- serde_urlencoded::from_str
- serde_urlencoded::to_string
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:c1118fb1af7658528e8f14e268068e22fbf2ae6cd3861fc1069b30b129301504","contract":["to_string serializes sequence of key-value pairs to URL-encoded query string","to_string percent-encodes special characters and spaces","from_str deserializes URL-encoded query string into sequence of key-value pairs","from_str decodes percent-encoded characters and plus signs","from_str returns error when value cannot be parsed into target type"],"goal":"verify pkg:cargo/serde_urlencoded@0.7.1","kind":"HOW","packages":["pkg:cargo/serde_urlencoded@0.7.1"],"schemaVersion":1,"symbols":["serde_urlencoded::from_str","serde_urlencoded::to_string"]},"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_urlencoded@0.7.1"],"schemaVersion":1,"subject":"pkg:cargo/serde_urlencoded@0.7.1","symbols":["serde_urlencoded::from_str","serde_urlencoded::to_string"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify pkg:cargo/serde_urlencoded@0.7.1",
"kind": "HOW",
"packages": [
"pkg:cargo/serde_urlencoded@0.7.1"
],
"symbols": [
"serde_urlencoded::from_str",
"serde_urlencoded::to_string"
]
}
//! Clean-room verification sample for serde_urlencoded.
pub use serde_urlencoded::*;
use serde_urlencoded::{from_str, to_string};
fn main() {
// 1. to_string serializes sequence of key-value pairs to URL-encoded query string
let params = &[("name", "alice"), ("role", "admin")];
let encoded = to_string(params).expect("failed to serialize params");
assert_eq!(encoded, "name=alice&role=admin");
// 2. to_string percent-encodes special characters and spaces
let special = &[("query", "hello world!"), ("tag", "a&b=c")];
let encoded_special = to_string(special).expect("failed to serialize special chars");
assert_eq!(encoded_special, "query=hello+world%21&tag=a%26b%3Dc");
// 3. from_str deserializes URL-encoded query string into sequence of key-value pairs
let input = "user=bob&status=active";
let decoded: Vec<(String, String)> = from_str(input).expect("failed to deserialize");
assert_eq!(
decoded,
vec![
("user".to_string(), "bob".to_string()),
("status".to_string(), "active".to_string()),
]
);
// 4. from_str decodes percent-encoded characters and plus signs
let encoded_input = "city=New+York&greeting=hello%20world";
let decoded_special: Vec<(String, String)> =
from_str(encoded_input).expect("failed to deserialize special");
assert_eq!(
decoded_special,
vec![
("city".to_string(), "New York".to_string()),
("greeting".to_string(), "hello world".to_string()),
]
);
// 5. from_str returns error when value cannot be parsed into target type
let invalid_int = "id=not_an_int";
let err = from_str::<Vec<(String, u32)>>(invalid_int);
assert!(err.is_err());
println!("All serde_urlencoded contract assertions passed successfully.");
}
原始种子者
匿名