Пример
socket2 0.6.5: socket2::Type
Проверенный пример — cargo socket2 0.6.5: socket2::Type. Контракт выполнен на rust 1 · linux alpine/x64 · docker и пройден: Type::STREAM and Type::DGRAM…
sha256:886656c0294e551e0017e6ea94296a91bf45b1f465659c0cd4c8a275c6849fbf
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
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 socket2::Type in pkg:cargo/socket2@0.6.5
- Пакеты
- Символы
-
- socket2::Type
- Создан
- 2026-09-20T16:27:44Z
Контракт
- Type::STREAM and Type::DGRAM provide distinct standard socket type constants
- Type::SEQPACKET, Type::RAW, and Type::DCCP provide extended socket types
- Type::nonblocking and Type::cloexec modify socket type flags
- Type converts to and from raw integer representation using From and Into
- Type supports Copy, Clone, and equality comparisons
Файлы
- 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 = "libc"
version = "0.2.189"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
[[package]]
name = "sample-socket2"
version = "1.0.0"
dependencies = [
"socket2",
]
[[package]]
name = "socket2"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4"
dependencies = [
"libc",
"windows-sys",
]
[[package]]
name = "windows-link"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
[[package]]
name = "windows-sys"
version = "0.61.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
dependencies = [
"windows-link",
]
[package]
name = "sample-socket2"
version = "1.0.0"
edition = "2021"
publish = false
[dependencies]
socket2 = { version = "=0.6.5", features = ["all"] }
[[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 socket2::Type in pkg:cargo/socket2@0.6.5
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/socket2@0.6.5
Demonstrate these symbols/APIs:
- socket2::Type
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:2f72509819a814ead549af3b29bd005548398d6efd41283d86dadee2a6db8a75","contract":["Type::STREAM and Type::DGRAM provide distinct standard socket type constants","Type::SEQPACKET, Type::RAW, and Type::DCCP provide extended socket types","Type::nonblocking and Type::cloexec modify socket type flags","Type converts to and from raw integer representation using From and Into","Type supports Copy, Clone, and equality comparisons"],"goal":"verify socket2::Type in pkg:cargo/socket2@0.6.5","kind":"HOW","packages":["pkg:cargo/socket2@0.6.5"],"schemaVersion":1,"symbols":["socket2::Type"]},"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/socket2@0.6.5"],"schemaVersion":1,"subject":"pkg:cargo/socket2@0.6.5","symbols":["socket2::Type"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify socket2::Type in pkg:cargo/socket2@0.6.5",
"kind": "HOW",
"packages": [
"pkg:cargo/socket2@0.6.5"
],
"symbols": [
"socket2::Type"
]
}
//! Clean-room verification sample for socket2.
pub use socket2::*;
use socket2::Type;
fn main() {
// 1. Type::STREAM and Type::DGRAM provide distinct standard socket type constants
let stream = Type::STREAM;
let dgram = Type::DGRAM;
assert_eq!(stream, Type::STREAM);
assert_ne!(stream, dgram);
// 2. Type::SEQPACKET, Type::RAW, and Type::DCCP provide extended socket types
let seqpacket = Type::SEQPACKET;
let raw = Type::RAW;
let dccp = Type::DCCP;
assert_ne!(stream, seqpacket);
assert_ne!(stream, raw);
assert_ne!(stream, dccp);
// 3. Type::nonblocking and Type::cloexec modify socket type flags
let stream_nb = stream.nonblocking();
let stream_cloexec = stream.cloexec();
let stream_both = stream.nonblocking().cloexec();
assert_ne!(stream, stream_nb);
assert_ne!(stream, stream_cloexec);
assert_ne!(stream_nb, stream_both);
// 4. Type converts to and from raw integer representation using From and Into
let raw_int: std::ffi::c_int = stream.into();
let reconstructed = Type::from(raw_int);
assert_eq!(stream, reconstructed);
let raw_int_dgram: std::ffi::c_int = dgram.into();
let reconstructed_dgram = Type::from(raw_int_dgram);
assert_eq!(dgram, reconstructed_dgram);
// 5. Type supports Copy, Clone, and equality comparisons
let copy_type = stream;
assert_eq!(copy_type, stream);
println!("All socket2::Type contract assertions passed successfully.");
}
Исходный сидер
аноним