CodeSampleX

Ejemplo

time-core 0.1.9: time_core

Muestra verificada para cargo time-core 0.1.9: time_core. El contrato se ejecutó en rust 1 · linux alpine/x64 · docker y pasó.

sha256:9f5d327fd7eba566c640f04d8b1cc9d5b674a09e27a45c68dc752ea74e054f43

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 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-10-31

Caso

HOW
Objetivo
verify time_core in pkg:cargo/time-core@0.1.9
Paquetes
Símbolos
  • time_core
Creado
2026-10-31T01:19:28Z

Contrato

  1. time_core::util::is_leap_year returns true for leap years (2000, 2024) and false for non-leap years (1900, 2025)
  2. time_core::util::days_in_year returns 366 for 2024 and 365 for 2025
  3. time_core::util::weeks_in_year returns 52 for 2019 and 53 for 2020
  4. time_core::util::days_in_month and days_in_month_leap return 29 for February in leap years and 28 in non-leap years
  5. time_core::unit types compute exact ratios via per and per_t (e.g. Second::per(Minute) == 60, Second::per(Day) == 86400) and compare against Unit enum variants

Archivos

  • Cargo.lock
  • Cargo.toml
  • PROMPT.md
  • csx.json
  • spec.json
  • src/main.rs

Descargar el artefacto de código fuente (tar.gz)

Código fuente

Cargo.lock
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4

[[package]]
name = "sample"
version = "0.1.0"
dependencies = [
 "time-core",
]

[[package]]
name = "time-core"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109"
Cargo.toml
[package]
name = "sample"
version = "0.1.0"
edition = "2021"

[dependencies]
time-core = "=0.1.9"
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 time_core in pkg:cargo/time-core@0.1.9
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/time-core@0.1.9
Demonstrate these symbols/APIs:
  - time_core

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:d5d0638674c70774008627574a9601f79e76ec92027003d91fd13796096c6d5a","contract":["time_core::util::is_leap_year returns true for leap years (2000, 2024) and false for non-leap years (1900, 2025)","time_core::util::days_in_year returns 366 for 2024 and 365 for 2025","time_core::util::weeks_in_year returns 52 for 2019 and 53 for 2020","time_core::util::days_in_month and days_in_month_leap return 29 for February in leap years and 28 in non-leap years","time_core::unit types compute exact ratios via per and per_t (e.g. Second::per(Minute) == 60, Second::per(Day) == 86400) and compare against Unit enum variants"],"goal":"verify time_core in pkg:cargo/time-core@0.1.9","kind":"HOW","packages":["pkg:cargo/time-core@0.1.9"],"schemaVersion":1,"symbols":["time_core"]},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","ecosystem":"cargo","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/time-core@0.1.9"],"schemaVersion":1,"subject":"pkg:cargo/time-core@0.1.9","symbols":["time_core"],"verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify time_core in pkg:cargo/time-core@0.1.9",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/time-core@0.1.9"
  ],
  "symbols": [
    "time_core"
  ]
}
src/main.rs
use time_core::unit::{Day, Hour, Microsecond, Millisecond, Minute, Nanosecond, Second, Unit, Week};
use time_core::util::{
    days_in_month, days_in_month_leap, days_in_year, is_leap_year, range_validated, weeks_in_year,
};

fn main() {
    // Leap year checks (proleptic Gregorian calendar)
    assert!(!is_leap_year(1900));
    assert!(is_leap_year(2000));
    assert!(is_leap_year(2024));
    assert!(!is_leap_year(2025));

    // Calendar days in year
    assert_eq!(days_in_year(2024), 366);
    assert_eq!(days_in_year(2025), 365);

    // ISO weeks in year
    assert_eq!(weeks_in_year(2019), 52);
    assert_eq!(weeks_in_year(2020), 53);

    // Days in month
    assert_eq!(days_in_month(2, 2024), 29);
    assert_eq!(days_in_month(2, 2025), 28);
    assert_eq!(days_in_month(1, 2025), 31);
    assert_eq!(days_in_month(4, 2025), 30);
    assert_eq!(days_in_month_leap(2, true), 29);
    assert_eq!(days_in_month_leap(2, false), 28);

    // Range-validated utilities
    assert!(range_validated::is_leap_year(2024));
    assert_eq!(range_validated::days_in_year(2024), 366);
    assert_eq!(range_validated::days_in_month(2, 2024), 29);

    // Unit conversions
    assert_eq!(Nanosecond::per(Microsecond), 1_000_u16);
    assert_eq!(Microsecond::per(Millisecond), 1_000_u16);
    assert_eq!(Millisecond::per(Second), 1_000_u16);
    assert_eq!(Second::per(Minute), 60_u8);
    assert_eq!(Minute::per(Hour), 60_u8);
    assert_eq!(Hour::per(Day), 24_u8);
    assert_eq!(Day::per(Week), 7_u8);
    assert_eq!(Second::per(Day), 86_400_u32);
    assert_eq!(Second::per_t::<u64>(Hour), 3_600_u64);

    // Unit enum comparisons
    assert_eq!(Unit::<1>::Second, Second::<1>);
    assert!(Second::<1> < Minute::<1>);
    assert!(Hour::<1> > Minute::<1>);
}

Seeder de origen

anónimo