CodeSampleX

Ejemplo

zerovec 0.11.6: zerovec::ule::CharULE

Muestra verificada para cargo zerovec 0.11.6: zerovec::ule::CharULE. El contrato se ejecutó en rust 1 · linux alpine/x64 · docker y pasó.

sha256:cebd8b3a34c0864676df311621f7cfdb8cbddbe780f5a381036718a6304800e2

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-21

Caso

HOW
Objetivo
verify zerovec::ule::CharULE in pkg:cargo/zerovec@0.11.6
Paquetes
Símbolos
  • zerovec::ule::CharULE
Creado
2026-09-21T12:36:50Z

Contrato

  1. CharULE converts to and from char directly and via AsULE trait
  2. CharULE encodes characters as 3 little-endian bytes without padding
  3. CharULE parses and validates byte slices rejecting non-multiple of 3 lengths and invalid codepoints
  4. CharULE preserves character equality and ordering semantics
  5. ZeroVec stores characters as unaligned CharULE elements

Archivos

  • Cargo.lock
  • Cargo.toml
  • PROMPT.md
  • csx.json
  • spec.json
  • src/lib.rs
  • test/contract.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-zerovec"
version = "1.0.0"
dependencies = [
 "zerovec",
]

[[package]]
name = "zerofrom"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272"

[[package]]
name = "zerovec"
version = "0.11.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90f911cbc359ab6af17377d242225f4d75119aec87ea711a880987b18cd7b239"
dependencies = [
 "zerofrom",
]
Cargo.toml
[package]
name = "sample-zerovec"
version = "1.0.0"
edition = "2021"
publish = false

[dependencies]
zerovec = "=0.11.6"

[[bin]]
name = "contract"
path = "test/contract.rs"
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 zerovec::ule::CharULE in pkg:cargo/zerovec@0.11.6
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/zerovec@0.11.6
Demonstrate these symbols/APIs:
  - zerovec::ule::CharULE

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:57cf464e14a2aab3162ac0e80051512802bdeed00292ccb514b2acd97d3b657c","contract":["CharULE converts to and from char directly and via AsULE trait","CharULE encodes characters as 3 little-endian bytes without padding","CharULE parses and validates byte slices rejecting non-multiple of 3 lengths and invalid codepoints","CharULE preserves character equality and ordering semantics","ZeroVec stores characters as unaligned CharULE elements"],"goal":"verify zerovec::ule::CharULE in pkg:cargo/zerovec@0.11.6","kind":"HOW","packages":["pkg:cargo/zerovec@0.11.6"],"schemaVersion":1,"symbols":["zerovec::ule::CharULE"]},"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/zerovec@0.11.6"],"schemaVersion":1,"subject":"pkg:cargo/zerovec@0.11.6","symbols":["zerovec::ule::CharULE"],"verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify zerovec::ule::CharULE in pkg:cargo/zerovec@0.11.6",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/zerovec@0.11.6"
  ],
  "symbols": [
    "zerovec::ule::CharULE"
  ]
}
src/lib.rs
//! Clean-room verification sample for zerovec.

pub use zerovec::*;
test/contract.rs
use std::cmp::Ordering;
use zerovec::ule::{AsULE, CharULE, ULE};
use zerovec::ZeroVec;

fn main() {
    // 1. CharULE converts to and from char directly and via AsULE trait
    let c = '🦀';
    let ule_direct = CharULE::from_aligned(c);
    assert_eq!(ule_direct.to_char(), c);

    let ule_trait: CharULE = c.to_unaligned();
    assert_eq!(char::from_unaligned(ule_trait), c);
    assert_eq!(ule_direct, ule_trait);

    let chars = ['a', 'Ω', '文', '🦀'];
    for &ch in &chars {
        let ule = ch.to_unaligned();
        assert_eq!(char::from_unaligned(ule), ch);
        assert_eq!(ule.to_char(), ch);
    }

    // 2. CharULE encodes characters as 3 little-endian bytes without padding
    let ascii_slice = ['a'.to_unaligned()];
    let ascii_bytes = CharULE::slice_as_bytes(&ascii_slice);
    assert_eq!(ascii_bytes, &[0x61, 0x00, 0x00]);

    // Crab emoji U+1F980 -> LE bytes: 0x80, 0xF9, 0x01
    let crab_slice = ['🦀'.to_unaligned()];
    let crab_bytes = CharULE::slice_as_bytes(&crab_slice);
    assert_eq!(crab_bytes, &[0x80, 0xF9, 0x01]);

    const ARRAY_CHARS: [char; 2] = ['a', 'b'];
    const ARRAY_ULES: [CharULE; 2] = CharULE::from_array(ARRAY_CHARS);
    assert_eq!(CharULE::slice_as_bytes(&ARRAY_ULES), &[0x61, 0x00, 0x00, 0x62, 0x00, 0x00]);

    // 3. CharULE parses and validates byte slices rejecting non-multiple of 3 lengths and invalid codepoints
    let valid_bytes = [0x61, 0x00, 0x00, 0x80, 0xF9, 0x01];
    let parsed = CharULE::parse_bytes_to_slice(&valid_bytes).expect("valid bytes");
    assert_eq!(parsed.len(), 2);
    assert_eq!(parsed[0].to_char(), 'a');
    assert_eq!(parsed[1].to_char(), '🦀');

    // Length not multiple of 3
    assert!(CharULE::parse_bytes_to_slice(&[0x61, 0x00]).is_err());
    assert!(CharULE::validate_bytes(&[0x61, 0x00]).is_err());

    // Surrogate codepoint 0xD800 (high surrogate) -> LE: 0x00, 0xD8, 0x00
    let surrogate_bytes = [0x00, 0xD8, 0x00];
    assert!(CharULE::parse_bytes_to_slice(&surrogate_bytes).is_err());
    assert!(CharULE::validate_bytes(&surrogate_bytes).is_err());

    // Out of range codepoint 0x20FFFF -> LE: 0xFF, 0xFF, 0x20
    let out_of_range = [0xFF, 0xFF, 0x20];
    assert!(CharULE::parse_bytes_to_slice(&out_of_range).is_err());
    assert!(CharULE::validate_bytes(&out_of_range).is_err());

    // 4. CharULE preserves character equality and ordering semantics
    let ule_a = 'a'.to_unaligned();
    let ule_b = 'b'.to_unaligned();
    let ule_a2 = 'a'.to_unaligned();

    assert_eq!(ule_a, ule_a2);
    assert_ne!(ule_a, ule_b);
    assert_eq!(ule_a.cmp(&ule_b), Ordering::Less);
    assert_eq!(ule_b.cmp(&ule_a), Ordering::Greater);
    assert_eq!(ule_a.cmp(&ule_a2), Ordering::Equal);
    assert!(ule_a < ule_b);

    // 5. ZeroVec stores characters as unaligned CharULE elements
    let zv = ZeroVec::<char>::parse_bytes(&valid_bytes).expect("valid zerovec bytes");
    assert_eq!(zv.get(0), Some('a'));
    assert_eq!(zv.get(1), Some('🦀'));
    assert_eq!(zv.get(2), None);
    assert_eq!(zv.as_bytes(), &valid_bytes);

    let zv_borrowed: ZeroVec<char> = ZeroVec::new_borrowed(&ARRAY_ULES);
    assert_eq!(zv_borrowed.get(0), Some('a'));
    assert_eq!(zv_borrowed.get(1), Some('b'));
    assert_eq!(zv_borrowed.get(2), None);

    println!("All zerovec::ule::CharULE contract assertions passed successfully.");
}

Seeder de origen

anónimo