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 で contract を実行し、成功しました.

sha256:3e243fe6715cbf27f09c56d57040ca0fdc6daf3a4ac147ca1cbae75ac2e258c6

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 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.");
}

オリジンシーダー

匿名