CodeSampleX

Sample

utf8_iter 1.0.4

Verified sample for cargo utf8_iter 1.0.4. The contract ran on rust 1 · linux alpine/x64 · docker and passed: Utf8Chars iterates over valid UTF-8 byte slices…

sha256:b3aa7576ee65d32e82dc45baefc108ce4e2a3310c5e19fd19b17c36a4221d7eb

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/utf8_iter@1.0.4
Packages
Created
2026-09-18T13:30:37Z

Contract

  1. Utf8Chars iterates over valid UTF-8 byte slices yielding decoded characters
  2. Utf8Chars replaces invalid UTF-8 byte sequences with Unicode replacement characters per WHATWG specification
  3. Utf8CharsEx trait provides chars and char_indices methods directly on byte slices
  4. Utf8Chars implements DoubleEndedIterator supporting reverse iteration over byte slices
  5. Utf8CharIndices provides byte offsets alongside decoded characters
  6. ErrorReportingUtf8Chars yields Ok(char) for valid code points and Err(Utf8CharsError) on invalid byte sequences

Files

  • Cargo.lock
  • Cargo.toml
  • PROMPT.md
  • csx.json
  • spec.json
  • src/lib.rs
  • test/contract.rs

Download the source artifact (tar.gz)

Source

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

[[package]]
name = "sample-utf8-iter"
version = "1.0.0"
dependencies = [
 "utf8_iter",
]

[[package]]
name = "utf8_iter"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
Cargo.toml
[package]
name = "sample-utf8-iter"
version = "1.0.0"
edition = "2021"
publish = false

[dependencies]
utf8_iter = "=1.0.4"

[[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 pkg:cargo/utf8_iter@1.0.4
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/utf8_iter@1.0.4

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:a0e564f4a2a56af558b784a0d267aec32f5c09a33822de5e0eb6b610720e8b96","contract":["Utf8Chars iterates over valid UTF-8 byte slices yielding decoded characters","Utf8Chars replaces invalid UTF-8 byte sequences with Unicode replacement characters per WHATWG specification","Utf8CharsEx trait provides chars and char_indices methods directly on byte slices","Utf8Chars implements DoubleEndedIterator supporting reverse iteration over byte slices","Utf8CharIndices provides byte offsets alongside decoded characters","ErrorReportingUtf8Chars yields Ok(char) for valid code points and Err(Utf8CharsError) on invalid byte sequences"],"goal":"verify pkg:cargo/utf8_iter@1.0.4","kind":"HOW","packages":["pkg:cargo/utf8_iter@1.0.4"],"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/utf8_iter@1.0.4"],"schemaVersion":1,"subject":"pkg:cargo/utf8_iter@1.0.4","verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:cargo/utf8_iter@1.0.4",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/utf8_iter@1.0.4"
  ]
}
src/lib.rs
//! Clean-room verification sample for utf8_iter.

pub use utf8_iter::*;
test/contract.rs
use utf8_iter::{ErrorReportingUtf8Chars, Utf8Chars, Utf8CharsEx};

fn main() {
    // 1. Utf8Chars iterates over valid UTF-8 byte slices yielding decoded characters
    let valid_bytes = "Hello, 世界! 🦀".as_bytes();
    let mut iter = Utf8Chars::new(valid_bytes);
    assert_eq!(iter.next(), Some('H'));
    assert_eq!(iter.next(), Some('e'));
    assert_eq!(iter.next(), Some('l'));
    assert_eq!(iter.next(), Some('l'));
    assert_eq!(iter.next(), Some('o'));
    assert_eq!(iter.next(), Some(','));
    assert_eq!(iter.next(), Some(' '));
    assert_eq!(iter.next(), Some('世'));
    assert_eq!(iter.next(), Some('界'));
    assert_eq!(iter.next(), Some('!'));
    assert_eq!(iter.next(), Some(' '));
    assert_eq!(iter.next(), Some('🦀'));
    assert_eq!(iter.next(), None);

    let mut slice_test = Utf8Chars::new(b"abc");
    assert_eq!(slice_test.as_slice(), b"abc");
    assert_eq!(slice_test.next(), Some('a'));
    assert_eq!(slice_test.as_slice(), b"bc");

    // 2. Utf8Chars replaces invalid UTF-8 byte sequences with Unicode replacement characters per WHATWG specification
    let invalid_bytes = b"foo\xFFbar\xC0\xAFbaz";
    let chars: Vec<char> = Utf8Chars::new(invalid_bytes).collect();
    assert_eq!(chars, vec!['f', 'o', 'o', '\u{FFFD}', 'b', 'a', 'r', '\u{FFFD}', '\u{FFFD}', 'b', 'a', 'z']);

    // 3. Utf8CharsEx trait provides chars and char_indices methods directly on byte slices
    let ex_bytes = b"rust-lang";
    let mut ex_iter = ex_bytes.chars();
    assert_eq!(ex_iter.next(), Some('r'));
    assert_eq!(ex_iter.next(), Some('u'));
    assert_eq!(ex_iter.next(), Some('s'));
    assert_eq!(ex_iter.next(), Some('t'));

    let mut idx_iter = ex_bytes.char_indices();
    assert_eq!(idx_iter.next(), Some((0, 'r')));
    assert_eq!(idx_iter.next(), Some((1, 'u')));

    // 4. Utf8Chars implements DoubleEndedIterator supporting reverse iteration over byte slices
    let rev_bytes = "abc".as_bytes();
    let mut rev_iter = Utf8Chars::new(rev_bytes);
    assert_eq!(rev_iter.next_back(), Some('c'));
    assert_eq!(rev_iter.next_back(), Some('b'));
    assert_eq!(rev_iter.next_back(), Some('a'));
    assert_eq!(rev_iter.next_back(), None);

    // 5. Utf8CharIndices provides byte offsets alongside decoded characters
    let multi_byte = "a🦀b".as_bytes();
    let indices: Vec<(usize, char)> = multi_byte.char_indices().collect();
    assert_eq!(indices, vec![(0, 'a'), (1, '🦀'), (5, 'b')]);

    // 6. ErrorReportingUtf8Chars yields Ok(char) for valid code points and Err(Utf8CharsError) on invalid byte sequences
    let mixed_bytes = b"a\xFFb";
    let mut report_iter = ErrorReportingUtf8Chars::new(mixed_bytes);
    assert_eq!(report_iter.next(), Some(Ok('a')));
    let err = report_iter.next().unwrap().unwrap_err();
    assert_eq!(err.to_string(), "byte sequence not well-formed UTF-8");
    assert_eq!(report_iter.next(), Some(Ok('b')));
    assert_eq!(report_iter.next(), None);

    println!("All utf8_iter contract assertions passed successfully.");
}

Origin Seeder

anonymous