CodeSampleX

Пример

miniz_oxide 0.8.9: miniz_oxide::deflate::CompressionLevel

Проверенный пример — cargo miniz_oxide 0.8.9: miniz_oxide::deflate::CompressionLevel. Контракт выполнен на rust 1 · linux alpine/x64 · docker и пройден.

sha256:3e243fe6715cbf27f09c56d57040ca0fdc6daf3a4ac147ca1cbae75ac2e258c6

Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла. Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди. MIT-0

Свидетельства выполнения

Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.

Основа свидетельства
Подписанный контракт пройден
Квитанции проверки
1
Ключи подписи, собравшие его
1
Заявленная среда linux x64 cargo

Среды запусков проверки

Окружение Контракт Этапы Запуск
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-20

Кейс

HOW
Цель
verify miniz_oxide::deflate::CompressionLevel in pkg:cargo/miniz_oxide@0.8.9
Пакеты
Символы
  • miniz_oxide::deflate::CompressionLevel
Создан
2026-09-20T19:58:38Z

Контракт

  1. CompressionLevel variants map to expected integer deflate levels including NoCompression, BestSpeed, DefaultLevel, BestCompression, and UberCompression
  2. CompressionLevel supports Debug formatting and standard equality comparisons
  3. CompressionLevel supports cloning, copy semantics, and hashing for collection storage
  4. CompressorOxide accepts CompressionLevel configuration via set_compression_level
  5. Data compressed with CompressionLevel round-trips through decompress_to_vec back to the original bytes

Файлы

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

Скачать артефакт с исходным кодом (tar.gz)

Исходный код

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

[[package]]
name = "adler2"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"

[[package]]
name = "miniz_oxide"
version = "0.8.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
dependencies = [
 "adler2",
]

[[package]]
name = "sample-miniz-oxide"
version = "1.0.0"
dependencies = [
 "miniz_oxide",
]
Cargo.toml
[package]
name = "sample-miniz-oxide"
version = "1.0.0"
edition = "2021"
publish = false

[dependencies]
miniz_oxide = "=0.8.9"

[[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 miniz_oxide::deflate::CompressionLevel in pkg:cargo/miniz_oxide@0.8.9
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/miniz_oxide@0.8.9
Demonstrate these symbols/APIs:
  - miniz_oxide::deflate::CompressionLevel

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:71e8fd6c4f798f1c0437e30d5153ece5560839a9203942f05c2a2fb61d3ab5bb","contract":["CompressionLevel variants map to expected integer deflate levels including NoCompression, BestSpeed, DefaultLevel, BestCompression, and UberCompression","CompressionLevel supports Debug formatting and standard equality comparisons","CompressionLevel supports cloning, copy semantics, and hashing for collection storage","CompressorOxide accepts CompressionLevel configuration via set_compression_level","Data compressed with CompressionLevel round-trips through decompress_to_vec back to the original bytes"],"goal":"verify miniz_oxide::deflate::CompressionLevel in pkg:cargo/miniz_oxide@0.8.9","kind":"HOW","packages":["pkg:cargo/miniz_oxide@0.8.9"],"schemaVersion":1,"symbols":["miniz_oxide::deflate::CompressionLevel"]},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","ecosystem":"cargo","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/miniz_oxide@0.8.9"],"schemaVersion":1,"subject":"pkg:cargo/miniz_oxide@0.8.9","symbols":["miniz_oxide::deflate::CompressionLevel"],"verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify miniz_oxide::deflate::CompressionLevel in pkg:cargo/miniz_oxide@0.8.9",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/miniz_oxide@0.8.9"
  ],
  "symbols": [
    "miniz_oxide::deflate::CompressionLevel"
  ]
}
src/lib.rs
//! Clean-room verification sample for miniz_oxide.

pub use miniz_oxide::*;
test/contract.rs
use miniz_oxide::deflate::core::CompressorOxide;
use miniz_oxide::deflate::{compress_to_vec, CompressionLevel};
use miniz_oxide::inflate::decompress_to_vec;
use std::collections::HashSet;

fn main() {
    // 1. CompressionLevel variants map to expected integer deflate levels including NoCompression, BestSpeed, DefaultLevel, BestCompression, and UberCompression
    assert_eq!(CompressionLevel::NoCompression as i32, 0);
    assert_eq!(CompressionLevel::BestSpeed as i32, 1);
    assert_eq!(CompressionLevel::DefaultLevel as i32, 6);
    assert_eq!(CompressionLevel::BestCompression as i32, 9);
    assert_eq!(CompressionLevel::UberCompression as i32, 10);
    assert_eq!(CompressionLevel::DefaultCompression as i32, -1);

    // 2. CompressionLevel supports Debug formatting and standard equality comparisons
    assert_eq!(format!("{:?}", CompressionLevel::BestSpeed), "BestSpeed");
    assert_eq!(format!("{:?}", CompressionLevel::NoCompression), "NoCompression");
    assert_eq!(CompressionLevel::BestSpeed, CompressionLevel::BestSpeed);
    assert_ne!(CompressionLevel::BestSpeed, CompressionLevel::BestCompression);

    // 3. CompressionLevel supports cloning, copy semantics, and hashing for collection storage
    let level_copy = CompressionLevel::DefaultLevel;
    let mut level_set = HashSet::new();
    level_set.insert(level_copy);
    level_set.insert(CompressionLevel::DefaultLevel);
    level_set.insert(CompressionLevel::UberCompression);
    assert_eq!(level_set.len(), 2);
    assert!(level_set.contains(&level_copy));

    // 4. CompressorOxide accepts CompressionLevel configuration via set_compression_level
    let mut compressor = CompressorOxide::default();
    compressor.set_compression_level(CompressionLevel::BestSpeed);
    compressor.set_compression_level(CompressionLevel::BestCompression);
    compressor.set_compression_level(CompressionLevel::NoCompression);

    // 5. Data compressed with CompressionLevel round-trips through decompress_to_vec back to the original bytes
    let payload = b"miniz_oxide clean-room contract verification test for CompressionLevel. Data repetition test 1234567890 1234567890.";
    let levels = [
        CompressionLevel::NoCompression,
        CompressionLevel::BestSpeed,
        CompressionLevel::DefaultLevel,
        CompressionLevel::BestCompression,
        CompressionLevel::UberCompression,
    ];

    for level in levels {
        let compressed = compress_to_vec(payload, level as u8);
        let decompressed = decompress_to_vec(&compressed).expect("decompression succeeds");
        assert_eq!(decompressed, payload);
    }

    // Verify compression ratio differences between NoCompression and BestCompression
    let compressed_none = compress_to_vec(payload, CompressionLevel::NoCompression as u8);
    let compressed_best = compress_to_vec(payload, CompressionLevel::BestCompression as u8);
    assert!(compressed_best.len() < compressed_none.len());

    println!("All miniz_oxide::deflate::CompressionLevel contract assertions passed successfully.");
}

Исходный сидер

аноним