Exemple
tokio-macros 2.7.2: tokio_macros::main, tokio_macros::test
Échantillon vérifié pour cargo tokio-macros 2.7.2: tokio_macros::main, tokio_macros::test. Le contrat s'est exécuté sur rust 1 · linux alpine/x64 · docker et…
sha256:8a849c6363e40421a5a80ddb99ab2e4fabeed26f4082ebc061ebd2ac3da82656
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
rust linux x64 rust rust cargo
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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-16 |
Cas
HOW- Objectif
- verify pkg:cargo/tokio-macros@2.7.2
- Paquets
- Symboles
-
- tokio_macros::main
- tokio_macros::test
- Environnement
- rust
- Créé
- 2026-09-16T22:16:19Z
Contrat
- tokio_macros::main transforms async function into synchronous entry point running on current_thread flavor
- tokio_macros::main supports multi_thread flavor and worker_threads parameter
- tokio_macros::main accepts crate parameter to redirect runtime path
- tokio_macros::test generates executable async test runner with current_thread and multi_thread flavors
Fichiers
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- src/main.rs
- test/contract.rs
Code source
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "proc-macro2"
version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
dependencies = [
"proc-macro2",
]
[[package]]
name = "syn"
version = "3.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12df2e0110f65b775f769bb17ef989067a1d931b2eb822bd4346631eeada89f9"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "tokio-macros"
version = "2.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tokio_macros_sample"
version = "0.1.0"
dependencies = [
"tokio-macros",
]
[[package]]
name = "unicode-ident"
version = "1.0.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab72a15cf68d77cb0987d3684aa8a45c5ef827e8cb49ee2f30bfd7ba2feb519f"
[package]
name = "tokio_macros_sample"
version = "0.1.0"
edition = "2021"
[dependencies]
tokio-macros = "=2.7.2"
[lib]
name = "tokio_macros_sample"
path = "src/lib.rs"
[[bin]]
name = "tokio_macros_sample"
path = "src/main.rs"
[[test]]
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/tokio-macros@2.7.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/tokio-macros@2.7.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:9f1bebea96ff7ac40557abc6559b738843d617ee13cc7a1fd4c413f41ac74999","contract":["tokio_macros::main transforms async function into synchronous entry point running on current_thread flavor","tokio_macros::main supports multi_thread flavor and worker_threads parameter","tokio_macros::main accepts crate parameter to redirect runtime path","tokio_macros::test generates executable async test runner with current_thread and multi_thread flavors"],"goal":"verify pkg:cargo/tokio-macros@2.7.2","kind":"HOW","packages":["pkg:cargo/tokio-macros@2.7.2"],"schemaVersion":1,"symbols":["tokio_macros::main","tokio_macros::test"]},"contractCommand":["cargo","test","--offline"],"environment":{"arch":"x64","ecosystem":"cargo","executionContext":"rust","language":"rust","os":"linux","packageManager":"cargo","runtime":"rust","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/tokio-macros@2.7.2"],"schemaVersion":1,"subject":"pkg:cargo/tokio-macros@2.7.2","symbols":["tokio_macros::main","tokio_macros::test"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify pkg:cargo/tokio-macros@2.7.2",
"kind": "HOW",
"packages": [
"pkg:cargo/tokio-macros@2.7.2"
],
"symbols": [
"tokio_macros::main",
"tokio_macros::test"
]
}
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll, RawWaker, RawWakerVTable, Waker};
pub use tokio_macros::{main, test};
#[macro_export]
macro_rules! pin {
($($x:ident),*) => { $(
let mut $x = $x;
#[allow(unused_mut)]
let mut $x = unsafe {
::core::pin::Pin::new_unchecked(&mut $x)
};
)* }
}
pub mod runtime {
use super::*;
fn dummy_raw_waker() -> RawWaker {
fn noop(_: *const ()) {}
fn clone(p: *const ()) -> RawWaker {
RawWaker::new(p, &VTABLE)
}
static VTABLE: RawWakerVTable = RawWakerVTable::new(clone, noop, noop, noop);
RawWaker::new(std::ptr::null(), &VTABLE)
}
#[derive(Debug, Default)]
pub struct Runtime {
pub flavor: &'static str,
pub worker_threads: Option<usize>,
}
impl Runtime {
pub fn block_on<F: Future>(&self, mut future: F) -> F::Output {
let waker = unsafe { Waker::from_raw(dummy_raw_waker()) };
let mut cx = Context::from_waker(&waker);
let mut pinned = unsafe { Pin::new_unchecked(&mut future) };
match pinned.as_mut().poll(&mut cx) {
Poll::Ready(res) => res,
Poll::Pending => panic!("Future did not resolve immediately in contract test"),
}
}
}
#[derive(Debug, Default)]
pub struct Builder {
pub flavor: &'static str,
pub worker_threads: Option<usize>,
pub start_paused: bool,
pub name: Option<String>,
}
impl Builder {
pub fn new_current_thread() -> Self {
Self {
flavor: "current_thread",
..Default::default()
}
}
pub fn new_multi_thread() -> Self {
Self {
flavor: "multi_thread",
..Default::default()
}
}
pub fn worker_threads(&mut self, val: usize) -> &mut Self {
self.worker_threads = Some(val);
self
}
pub fn start_paused(&mut self, val: bool) -> &mut Self {
self.start_paused = val;
self
}
pub fn name(&mut self, val: &str) -> &mut Self {
self.name = Some(val.to_string());
self
}
pub fn enable_all(&mut self) -> &mut Self {
self
}
pub fn build(&mut self) -> Result<Runtime, &'static str> {
Ok(Runtime {
flavor: self.flavor,
worker_threads: self.worker_threads,
})
}
}
}
use tokio_macros_sample as tokio;
#[tokio_macros::main(flavor = "current_thread")]
async fn main() {
println!("tokio_macros::main entry point executed");
}
use tokio_macros_sample as tokio;
#[tokio_macros::main(flavor = "current_thread")]
async fn sample_current_thread_fn() -> i32 {
42
}
#[tokio_macros::main(flavor = "multi_thread", worker_threads = 4)]
async fn sample_multi_thread_fn() -> &'static str {
"multi_thread_ok"
}
#[tokio_macros::main(flavor = "current_thread", crate = "tokio_macros_sample")]
async fn sample_custom_crate_fn() -> bool {
true
}
#[tokio_macros::test]
async fn test_macro_with_default_crate() {
let result = sample_current_thread_fn();
assert_eq!(result, 42);
}
#[tokio_macros::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_macro_multi_thread() {
let result = sample_multi_thread_fn();
assert_eq!(result, "multi_thread_ok");
}
#[tokio_macros::test(flavor = "current_thread", crate = "tokio_macros_sample")]
async fn test_macro_with_custom_crate_option() {
let result = sample_custom_crate_fn();
assert!(result);
}
Seeder d'origine
anonyme