サンプル
hyper 1.12.0: hyper::Method, hyper::Request, hyper::Response
検証済みサンプル — cargo hyper 1.12.0: hyper::Method, hyper::Request, hyper::Response. rust 1 · linux alpine/x64 · docker で contract を実行し、成功しました.
sha256:24cc8c0b37bcfa64c2812bdf8d7faa9043c6f0e4747e5ebce4ed0e36fa5691d6
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
rust linux x64 rust rust 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-07 |
ケース
HOW- ゴール
- verify pkg:cargo/hyper@1.12.0
- パッケージ
- シンボル
-
- hyper::Method
- hyper::Request
- hyper::Response
- hyper::StatusCode
- hyper::service::service_fn
- 環境
- rust
- 作成日
- 2026-11-07T07:50:58Z
コントラクト
- assert hyper::Request::builder constructs GET, POST, and DELETE requests with method, URI, HTTP/1.1 version, and string body
- assert hyper::service::service_fn wraps a request handler and Service::call returns a future resolving to hyper::Response
- assert hyper::Response::builder sets StatusCode (OK, CREATED, NOT_FOUND), Version::HTTP_11, and CONTENT_TYPE header
ファイル
- Cargo.lock
- Cargo.toml
- NOTES.md
- PROMPT.md
- csx.json
- spec.json
- src/main.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.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c3e324da4c95177d6291d4c8730197c0d1822f8a9766814a4a44fa5ab797c9c"
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 = "0.1.0"
dependencies = [
"hyper",
]
[[package]]
name = "tokio"
version = "1.54.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3"
dependencies = [
"pin-project-lite",
]
[package]
name = "sample-hyper"
version = "0.1.0"
edition = "2021"
[dependencies]
hyper = "=1.12.0"
### Search Result
`search_known_solution` returned `NO_SAFE_MATCH` for `pkg:cargo/hyper@1.12.0`.
### Implementation Notes
`hyper@1.12.0` provides core HTTP types (`Request`, `Response`, `Method`, `StatusCode`, `Version`, `header`) and the `Service` / `service_fn` abstraction without requiring feature flags when constructing and invoking in-memory HTTP services.
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/hyper@1.12.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/hyper@1.12.0
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:2dac85d9553ffefe1432bce13926e8afff55c8d407e52b11e7c30898170be9c2","contract":["assert hyper::Request::builder constructs GET, POST, and DELETE requests with method, URI, HTTP/1.1 version, and string body","assert hyper::service::service_fn wraps a request handler and Service::call returns a future resolving to hyper::Response","assert hyper::Response::builder sets StatusCode (OK, CREATED, NOT_FOUND), Version::HTTP_11, and CONTENT_TYPE header"],"goal":"verify pkg:cargo/hyper@1.12.0","kind":"HOW","packages":["pkg:cargo/hyper@1.12.0"],"schemaVersion":1,"symbols":["hyper::Method","hyper::Request","hyper::Response","hyper::StatusCode","hyper::service::service_fn"]},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","ecosystem":"cargo","executionContext":"rust","language":"rust","os":"linux","packageManager":"cargo","runtime":"rust","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/hyper@1.12.0"],"schemaVersion":1,"subject":"pkg:cargo/hyper@1.12.0","symbols":["hyper::Method","hyper::Request","hyper::Response","hyper::StatusCode","hyper::service::service_fn"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify pkg:cargo/hyper@1.12.0",
"kind": "HOW",
"packages": [
"pkg:cargo/hyper@1.12.0"
]
}
use std::convert::Infallible;
use std::future::{ ready, Future, Ready };
use hyper::body::{ Body, Frame };
use hyper::header::{ HeaderValue, CONTENT_TYPE };
use hyper::service::{ service_fn, Service };
use hyper::{ Method, Request, Response, StatusCode, Version };
fn handle_request(req: Request<String>) -> Ready<Result<Response<String>, Infallible>> {
let method = req.method().clone();
let path = req.uri().path().to_string();
let body = req.into_body();
let (status, resp_body) = match (method, path.as_str()) {
(Method::GET, "/health") => (StatusCode::OK, "ok".to_string()),
(Method::POST, "/echo") => (StatusCode::CREATED, format!("echo:{}", body)),
_ => (StatusCode::NOT_FOUND, "not found".to_string()),
};
let mut resp = Response::builder()
.status(status)
.version(Version::HTTP_11)
.body(resp_body)
.expect("valid response");
resp.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_static("text/plain; charset=utf-8")
);
ready(Ok(resp))
}
fn poll_ready_future<F: Future>(fut: F) -> F::Output {
use std::pin::Pin;
use std::task::{ Context, Poll, RawWaker, RawWakerVTable, Waker };
fn noop_clone(_: *const ()) -> RawWaker {
RawWaker::new(std::ptr::null(), &VTABLE)
}
fn noop(_: *const ()) {}
static VTABLE: RawWakerVTable = RawWakerVTable::new(noop_clone, noop, noop, noop);
let waker = unsafe { Waker::from_raw(RawWaker::new(std::ptr::null(), &VTABLE)) };
let mut cx = Context::from_waker(&waker);
let mut pinned = Box::pin(fut);
match Pin::as_mut(&mut pinned).poll(&mut cx) {
Poll::Ready(val) => val,
Poll::Pending => panic!("expected immediate ready future"),
}
}
fn main() {
let svc = service_fn(handle_request);
let get_req = Request::builder()
.method(Method::GET)
.uri("http://localhost/health")
.version(Version::HTTP_11)
.body(String::new())
.expect("valid GET request");
let get_resp = poll_ready_future(svc.call(get_req)).expect("infallible service");
assert_eq!(get_resp.status(), StatusCode::OK);
assert_eq!(get_resp.version(), Version::HTTP_11);
assert_eq!(
get_resp.headers().get(CONTENT_TYPE).and_then(|v| v.to_str().ok()),
Some("text/plain; charset=utf-8")
);
assert_eq!(get_resp.into_body(), "ok");
let post_req = Request::builder()
.method(Method::POST)
.uri("http://localhost/echo")
.body("payload".to_string())
.expect("valid POST request");
assert!(!post_req.body().is_end_stream() || post_req.body() == "payload");
let post_resp = poll_ready_future(svc.call(post_req)).expect("infallible service");
assert_eq!(post_resp.status(), StatusCode::CREATED);
assert_eq!(post_resp.into_body(), "echo:payload");
let missing_req = Request::builder()
.method(Method::DELETE)
.uri("http://localhost/missing")
.body(String::new())
.expect("valid DELETE request");
let missing_resp = poll_ready_future(svc.call(missing_req)).expect("infallible service");
assert_eq!(missing_resp.status(), StatusCode::NOT_FOUND);
assert_eq!(missing_resp.into_body(), "not found");
let _frame = Frame::data("chunk");
println!("CONTRACT_OK");
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn contract_hyper_service_and_types() {
main();
}
}
オリジンシーダー
匿名