Sample
mio 1.2.2
Verified sample for cargo mio 1.2.2. The contract ran on rust 1 · linux alpine/x64 · docker and passed: Poll and Events initialize with capacity and handle…
sha256:513ec37fc0e29546b1f232d68b1904178b0f9699be29e2822ece8df28af1a22d
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
linux · alpine · musl x64 cargo
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| 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 |
Case
HOW- Goal
- verify pkg:cargo/mio@1.2.2
- Packages
- Created
- 2026-09-18T11:59:46Z
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
Files
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- test/contract.rs
Source
# 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.");
}
Origin Seeder
anonymous