CodeSampleX

Пример

hyper 1.12.0: hyper::Version

Проверенный пример — cargo hyper 1.12.0: hyper::Version. Контракт выполнен на rust 1 · linux alpine/x64 · docker и пройден: hyper::Version::default() returns…

sha256:dd7667a4e5e096a833a030152b7c1eb8b619255b4df21c12261ea881594e6c33

Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла. Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди. 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-07

Кейс

HOW
Цель
verify hyper::Version in pkg:cargo/hyper@1.12.0
Пакеты
Символы
  • hyper::Version
Создан
2026-11-07T17:23:43Z

Контракт

  1. hyper::Version::default() returns Version::HTTP_11 and formats as "HTTP/1.1" via Debug.
  2. hyper::Version provides constants HTTP_09, HTTP_10, HTTP_11, HTTP_2, and HTTP_3 with Debug strings "HTTP/0.9", "HTTP/1.0", "HTTP/1.1", "HTTP/2.0", and "HTTP/3.0".
  3. hyper::Version implements Ord in ascending protocol order (HTTP_09 < HTTP_10 < HTTP_11 < HTTP_2 < HTTP_3).
  4. hyper::Request::builder().version() and Request::version_mut() configure and mutate the request's hyper::Version.
  5. hyper::Response::builder().version() and Response::version_mut() configure and mutate the response's hyper::Version.

Файлы

  • Cargo.lock
  • Cargo.toml
  • PROMPT.md
  • csx.json
  • spec.json
  • src/lib.rs
  • test/contract.rs

Скачать артефакт с исходным кодом (tar.gz)

Исходный код

Cargo.lock
# 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"
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",
]
Cargo.toml
[package]
name = "sample-hyper-version"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
hyper = "=1.12.0"

[[bin]]
name = "contract"
path = "test/contract.rs"
PROMPT.md
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::Version in pkg:cargo/hyper@1.12.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/hyper@1.12.0
Demonstrate these symbols/APIs:
  - hyper::Version

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.
csx.json
{"case":{"caseId":"case:sha256:f5682d190c1e84c65cc24f34721aacbd6ae3c850b7fe4c7b72d78e2056d181a0","contract":["hyper::Version::default() returns Version::HTTP_11 and formats as \"HTTP/1.1\" via Debug.","hyper::Version provides constants HTTP_09, HTTP_10, HTTP_11, HTTP_2, and HTTP_3 with Debug strings \"HTTP/0.9\", \"HTTP/1.0\", \"HTTP/1.1\", \"HTTP/2.0\", and \"HTTP/3.0\".","hyper::Version implements Ord in ascending protocol order (HTTP_09 \u003c HTTP_10 \u003c HTTP_11 \u003c HTTP_2 \u003c HTTP_3).","hyper::Request::builder().version() and Request::version_mut() configure and mutate the request's hyper::Version.","hyper::Response::builder().version() and Response::version_mut() configure and mutate the response's hyper::Version."],"goal":"verify hyper::Version in pkg:cargo/hyper@1.12.0","kind":"HOW","packages":["pkg:cargo/hyper@1.12.0"],"schemaVersion":1,"symbols":["hyper::Version"]},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","ecosystem":"cargo","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/hyper@1.12.0"],"schemaVersion":1,"subject":"pkg:cargo/hyper@1.12.0","symbols":["hyper::Version"],"verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify hyper::Version in pkg:cargo/hyper@1.12.0",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/hyper@1.12.0"
  ],
  "symbols": [
    "hyper::Version"
  ]
}
src/lib.rs
pub use hyper::{Request, Response, Version};
test/contract.rs
use hyper::{Request, Response, Version};

fn main() {
    // 1. Version::default() returns Version::HTTP_11
    let default_ver = Version::default();
    assert_eq!(default_ver, Version::HTTP_11);
    assert_eq!(format!("{:?}", default_ver), "HTTP/1.1");

    // 2. All HTTP version constants have distinct values and canonical Debug strings
    assert_eq!(format!("{:?}", Version::HTTP_09), "HTTP/0.9");
    assert_eq!(format!("{:?}", Version::HTTP_10), "HTTP/1.0");
    assert_eq!(format!("{:?}", Version::HTTP_11), "HTTP/1.1");
    assert_eq!(format!("{:?}", Version::HTTP_2), "HTTP/2.0");
    assert_eq!(format!("{:?}", Version::HTTP_3), "HTTP/3.0");

    // 3. Version implements Ord in chronological protocol order
    assert!(Version::HTTP_09 < Version::HTTP_10);
    assert!(Version::HTTP_10 < Version::HTTP_11);
    assert!(Version::HTTP_11 < Version::HTTP_2);
    assert!(Version::HTTP_2 < Version::HTTP_3);

    // 4. Request::builder().version() and Request::version_mut() set and update hyper::Version
    let mut req = Request::builder()
        .version(Version::HTTP_2)
        .uri("http://example.com/")
        .body(())
        .expect("valid request");
    assert_eq!(req.version(), Version::HTTP_2);
    *req.version_mut() = Version::HTTP_11;
    assert_eq!(req.version(), Version::HTTP_11);

    // 5. Response::builder().version() and Response::version_mut() set and update hyper::Version
    let mut res = Response::builder()
        .version(Version::HTTP_3)
        .status(200)
        .body(())
        .expect("valid response");
    assert_eq!(res.version(), Version::HTTP_3);
    *res.version_mut() = Version::HTTP_2;
    assert_eq!(res.version(), Version::HTTP_2);
}

Исходный сидер

аноним