Ejemplo
mio 1.2.2
Muestra verificada para cargo mio 1.2.2. El contrato se ejecutó en rust 1 · linux alpine/x64 · docker y pasó: Poll and Events initialize with capacity and…
sha256:513ec37fc0e29546b1f232d68b1904178b0f9699be29e2822ece8df28af1a22d
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 1
- Claves de firma que lo compilaron
- 1
Entorno declarado
linux · alpine · musl x64 cargo
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| 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 |
Caso
HOW- Objetivo
- verify pkg:cargo/mio@1.2.2
- Paquetes
- Creado
- 2026-09-18T11:59:46Z
Contrato
- Poll and Events initialize with capacity and handle empty poll timeout
- Interest combines readable and writable readiness states
- Waker registers with Poll registry and wakes poll waiting on events
- TcpListener and TcpStream bind, register, and transmit bytes across non-blocking connection
Archivos
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- test/contract.rs
Código fuente
# 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 = "log"
version = "0.4.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
[[package]]
name = "mio"
version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30d65c71f1ce40ab09135ce117d742b9f8a19ff91a41a8b57ed50bc2de59c427"
dependencies = [
"libc",
"log",
"wasi",
"windows-sys",
]
[[package]]
name = "sample-mio"
version = "1.0.0"
dependencies = [
"mio",
]
[[package]]
name = "wasi"
version = "0.11.1+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
[[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-mio"
version = "1.0.0"
edition = "2021"
publish = false
[dependencies]
mio = { version = "=1.2.2", features = ["os-poll", "net"] }
[[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/mio@1.2.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/mio@1.2.2
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:d62cebf97ea061788e8b51d37a8167ff9d622461beb505f4fef53fcdac9fbeee","contract":["Poll and Events initialize with capacity and handle empty poll timeout","Interest combines readable and writable readiness states","Waker registers with Poll registry and wakes poll waiting on events","TcpListener and TcpStream bind, register, and transmit bytes across non-blocking connection"],"goal":"verify pkg:cargo/mio@1.2.2","kind":"HOW","packages":["pkg:cargo/mio@1.2.2"],"schemaVersion":1},"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/mio@1.2.2"],"schemaVersion":1,"subject":"pkg:cargo/mio@1.2.2","verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify pkg:cargo/mio@1.2.2",
"kind": "HOW",
"packages": [
"pkg:cargo/mio@1.2.2"
]
}
//! Clean-room verification sample for mio.
pub use mio::*;
use mio::net::{TcpListener, TcpStream};
use mio::{Events, Interest, Poll, Token, Waker};
use std::io::{Read, Write};
use std::time::Duration;
fn main() {
// 1. Poll and Events initialize with capacity and handle empty poll timeout
let mut poll = Poll::new().expect("Failed to create Poll instance");
let mut events = Events::with_capacity(64);
assert!(events.is_empty());
assert_eq!(events.capacity(), 64);
poll.poll(&mut events, Some(Duration::from_millis(10)))
.expect("Poll timed out or errored");
assert!(events.is_empty());
// 2. Interest combines readable and writable readiness states
let read = Interest::READABLE;
let write = Interest::WRITABLE;
let combined = read.add(write);
assert!(combined.is_readable());
assert!(combined.is_writable());
assert!(read.is_readable());
assert!(!read.is_writable());
assert!(!write.is_readable());
assert!(write.is_writable());
// 3. Waker registers with Poll registry and wakes poll waiting on events
const WAKER_TOKEN: Token = Token(10);
let waker = Waker::new(poll.registry(), WAKER_TOKEN).expect("Failed to create Waker");
waker.wake().expect("Failed to wake Poll");
poll.poll(&mut events, Some(Duration::from_millis(100)))
.expect("Failed to poll for waker event");
assert!(!events.is_empty());
let mut waker_found = false;
for event in events.iter() {
if event.token() == WAKER_TOKEN && event.is_readable() {
waker_found = true;
}
}
assert!(waker_found, "Waker event was not observed");
// 4. TcpListener and TcpStream bind, register, and transmit bytes across non-blocking connection
const LISTENER_TOKEN: Token = Token(1);
const CLIENT_TOKEN: Token = Token(2);
const SERVER_STREAM_TOKEN: Token = Token(3);
let mut listener = TcpListener::bind("127.0.0.1:0".parse().unwrap())
.expect("Failed to bind TcpListener to loopback");
let addr = listener.local_addr().expect("Failed to get local address");
poll.registry()
.register(&mut listener, LISTENER_TOKEN, Interest::READABLE)
.expect("Failed to register TcpListener");
let mut client = TcpStream::connect(addr).expect("Failed to connect TcpStream");
poll.registry()
.register(&mut client, CLIENT_TOKEN, Interest::WRITABLE | Interest::READABLE)
.expect("Failed to register client TcpStream");
let mut server_stream = None;
let mut client_writable = false;
for _ in 0..20 {
events.clear();
poll.poll(&mut events, Some(Duration::from_millis(100)))
.expect("Failed to poll connection events");
for event in events.iter() {
if event.token() == LISTENER_TOKEN && event.is_readable() {
if let Ok((stream, _)) = listener.accept() {
server_stream = Some(stream);
}
}
if event.token() == CLIENT_TOKEN && event.is_writable() {
client_writable = true;
}
}
if server_stream.is_some() && client_writable {
break;
}
}
assert!(server_stream.is_some(), "Listener never accepted connection");
let mut server = server_stream.unwrap();
poll.registry()
.register(&mut server, SERVER_STREAM_TOKEN, Interest::READABLE)
.expect("Failed to register server stream");
// Send data from client to server
let payload = b"mio ping test";
let n = client.write(payload).expect("Client failed to write bytes");
assert_eq!(n, payload.len());
let mut received = Vec::new();
let mut buf = [0u8; 64];
for _ in 0..20 {
events.clear();
poll.poll(&mut events, Some(Duration::from_millis(100)))
.expect("Failed to poll read events");
for event in events.iter() {
if event.token() == SERVER_STREAM_TOKEN && event.is_readable() {
match server.read(&mut buf) {
Ok(read_bytes) if read_bytes > 0 => {
received.extend_from_slice(&buf[..read_bytes]);
}
_ => {}
}
}
}
if received.len() >= payload.len() {
break;
}
}
assert_eq!(&received[..], payload, "Transmitted payload does not match received");
println!("All mio contract assertions passed successfully.");
}
Seeder de origen
anónimo