示例
hyper 1.11.0: hyper
已验证示例 — cargo hyper 1.11.0: hyper. contract 在 rust 1 · linux alpine/x64 · docker 上运行并通过: Request builder creates HTTP requests with method, uri, and headers
sha256:93b604051424e025b7bbd33a8ac8fff3ce1910e2675f64e592caec480a0a4e31
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 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-20 |
案例
HOW- 目标
- verify hyper in pkg:cargo/hyper@1.11.0
- 符号
-
- hyper
- 创建时间
- 2026-09-20T13:01:39Z
契约
- Request builder creates HTTP requests with method, uri, and headers
- Response builder creates HTTP responses with status code and headers
- StatusCode checks HTTP status classes and classification
- Method parses standard methods and supports custom method names
- SizeHint calculates upper, lower, and exact body size boundaries
- Frame wraps data chunks and trailer headers
- service_fn wraps a closure into a Service handling requests asynchronously
文件
- 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 = "bytes"
version = "1.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
[[package]]
name = "http"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0"
dependencies = [
"bytes",
"itoa",
]
[[package]]
name = "http-body"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c"
dependencies = [
"bytes",
"http",
]
[[package]]
name = "hyper"
version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d22053281f852e11534f5198498373cbb59295120a20771d90f7ed1897490a72"
dependencies = [
"bytes",
"http",
"http-body",
"tokio",
]
[[package]]
name = "itoa"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
[[package]]
name = "pin-project-lite"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
[[package]]
name = "sample-hyper"
version = "1.0.0"
dependencies = [
"hyper",
]
[[package]]
name = "tokio"
version = "1.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed"
dependencies = [
"pin-project-lite",
]
[package]
name = "sample-hyper"
version = "1.0.0"
edition = "2021"
publish = false
[dependencies]
hyper = "=1.11.0"
[[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 hyper in pkg:cargo/hyper@1.11.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/hyper@1.11.0
Demonstrate these symbols/APIs:
- hyper
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:3adff5856e43ad361fe787cb83c085c8cb4ab6658a970b42d434309d3f051415","contract":["Request builder creates HTTP requests with method, uri, and headers","Response builder creates HTTP responses with status code and headers","StatusCode checks HTTP status classes and classification","Method parses standard methods and supports custom method names","SizeHint calculates upper, lower, and exact body size boundaries","Frame wraps data chunks and trailer headers","service_fn wraps a closure into a Service handling requests asynchronously"],"goal":"verify hyper in pkg:cargo/hyper@1.11.0","kind":"HOW","packages":["pkg:cargo/hyper@1.11.0"],"schemaVersion":1,"symbols":["hyper"]},"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/hyper@1.11.0"],"schemaVersion":1,"subject":"pkg:cargo/hyper@1.11.0","symbols":["hyper"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify hyper in pkg:cargo/hyper@1.11.0",
"kind": "HOW",
"packages": [
"pkg:cargo/hyper@1.11.0"
],
"symbols": [
"hyper"
]
}
//! Clean-room verification sample for hyper.
pub use hyper::*;
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll, RawWaker, RawWakerVTable, Waker};
use hyper::body::{Body, Bytes, Frame, SizeHint};
use hyper::service::{service_fn, Service};
use hyper::{Method, Request, Response, StatusCode, Version};
struct EmptyBody;
impl Body for EmptyBody {
type Data = Bytes;
type Error = std::convert::Infallible;
fn poll_frame(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
) -> Poll<Option<Result<Frame<Self::Data>, Self::Error>>> {
Poll::Ready(None)
}
}
fn dummy_waker() -> Waker {
fn noop(_: *const ()) {}
fn clone(p: *const ()) -> RawWaker {
RawWaker::new(p, &VTABLE)
}
static VTABLE: RawWakerVTable = RawWakerVTable::new(clone, noop, noop, noop);
unsafe { Waker::from_raw(RawWaker::new(std::ptr::null(), &VTABLE)) }
}
fn main() {
// 1. Request builder creates HTTP requests with method, uri, and headers
let req = Request::builder()
.method(Method::POST)
.uri("https://example.com/api/v1/resource")
.version(Version::HTTP_11)
.header("content-type", "application/json")
.header("accept", "application/json")
.body(EmptyBody)
.expect("valid request");
assert_eq!(req.method(), Method::POST);
assert_eq!(req.uri().path(), "/api/v1/resource");
assert_eq!(req.version(), Version::HTTP_11);
assert_eq!(
req.headers().get("content-type").unwrap(),
"application/json"
);
// 2. Response builder creates HTTP responses with status code and headers
let res = Response::builder()
.status(StatusCode::CREATED)
.header("x-server-engine", "hyper")
.body(EmptyBody)
.expect("valid response");
assert_eq!(res.status(), StatusCode::CREATED);
assert!(res.status().is_success());
assert_eq!(res.headers().get("x-server-engine").unwrap(), "hyper");
// 3. StatusCode checks HTTP status classes and classification
assert!(StatusCode::OK.is_success());
assert!(StatusCode::MOVED_PERMANENTLY.is_redirection());
assert!(StatusCode::NOT_FOUND.is_client_error());
assert!(StatusCode::INTERNAL_SERVER_ERROR.is_server_error());
assert_eq!(StatusCode::from_u16(404).unwrap(), StatusCode::NOT_FOUND);
// 4. Method parses standard methods and supports custom method names
assert_eq!(Method::GET.as_str(), "GET");
assert_eq!(Method::POST.as_str(), "POST");
let custom_method = Method::from_bytes(b"PURGE").expect("valid custom method");
assert_eq!(custom_method.as_str(), "PURGE");
// 5. SizeHint calculates upper, lower, and exact body size boundaries
let mut hint = SizeHint::new();
hint.set_exact(1024);
assert_eq!(hint.lower(), 1024);
assert_eq!(hint.upper(), Some(1024));
assert_eq!(hint.exact(), Some(1024));
// 6. Frame wraps data chunks and trailer headers
let frame = Frame::data(Bytes::from_static(b"hello hyper"));
assert!(frame.is_data());
assert!(!frame.is_trailers());
assert_eq!(frame.data_ref().unwrap().as_ref(), b"hello hyper");
// 7. service_fn wraps a closure into a Service handling requests asynchronously
let service = service_fn(|req: Request<EmptyBody>| async move {
let status = if req.uri().path() == "/ping" {
StatusCode::OK
} else {
StatusCode::NOT_FOUND
};
Ok::<_, std::convert::Infallible>(
Response::builder()
.status(status)
.body(EmptyBody)
.unwrap(),
)
});
let ping_req = Request::builder()
.uri("/ping")
.body(EmptyBody)
.unwrap();
let mut fut = std::pin::pin!(service.call(ping_req));
let waker = dummy_waker();
let mut cx = Context::from_waker(&waker);
match fut.as_mut().poll(&mut cx) {
Poll::Ready(Ok(resp)) => {
assert_eq!(resp.status(), StatusCode::OK);
}
_ => panic!("service future did not resolve immediately"),
}
println!("All hyper contract assertions passed successfully.");
}
原始种子者
匿名