샘플
block-buffer 0.10.4: block_buffer::BlockBuffer, block_buffer::Eager, block_buffer::Lazy
검증된 샘플 — cargo block-buffer 0.10.4: block_buffer::BlockBuffer, block_buffer::Eager, block_buffer::Lazy. rust 1 · linux alpine/x64 · docker에서 contract를 실행해…
sha256:7e4e314cb261f4a57ecfcadfca7e2ad3b2dca220d51198ab02ea4a651de8b4e0
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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-11-04 |
케이스
HOW- 목표
- verify pkg:cargo/block-buffer@0.10.4
- 심벌
-
- block_buffer::BlockBuffer
- block_buffer::Eager
- block_buffer::Lazy
- 생성일
- 2026-11-04T02:28:52Z
컨트랙트
- BlockBuffer::<U4, Eager>::digest_blocks yields full 4-byte blocks immediately and leaves trailing bytes at get_pos()
- BlockBuffer::<U4, Lazy>::digest_blocks retains one full block in the buffer (get_pos() == 4) until at least one subsequent byte arrives
- BlockBuffer::pad_with_zeros zero-pads the remaining tail bytes into a complete block and resets get_pos() to 0
파일
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/main.rs
- tests/contract.rs
소스
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "block-buffer"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
dependencies = [
"generic-array",
]
[[package]]
name = "generic-array"
version = "0.14.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2"
dependencies = [
"typenum",
"version_check",
]
[[package]]
name = "sample-block-buffer"
version = "0.1.0"
dependencies = [
"block-buffer",
]
[[package]]
name = "typenum"
version = "1.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
[[package]]
name = "version_check"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
[package]
name = "sample-block-buffer"
version = "0.1.0"
edition = "2021"
[dependencies]
block-buffer = "=0.10.4"
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/block-buffer@0.10.4
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/block-buffer@0.10.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.
{"case":{"caseId":"case:sha256:ad907691efa7a768b93c3246ce74cd0a081cceb6d6fade90a5fc14a75210f61f","contract":["BlockBuffer::\u003cU4, Eager\u003e::digest_blocks yields full 4-byte blocks immediately and leaves trailing bytes at get_pos()","BlockBuffer::\u003cU4, Lazy\u003e::digest_blocks retains one full block in the buffer (get_pos() == 4) until at least one subsequent byte arrives","BlockBuffer::pad_with_zeros zero-pads the remaining tail bytes into a complete block and resets get_pos() to 0"],"goal":"verify pkg:cargo/block-buffer@0.10.4","kind":"HOW","packages":["pkg:cargo/block-buffer@0.10.4"],"schemaVersion":1,"symbols":["block_buffer::BlockBuffer","block_buffer::Eager","block_buffer::Lazy"]},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","ecosystem":"cargo","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/block-buffer@0.10.4"],"schemaVersion":1,"subject":"pkg:cargo/block-buffer@0.10.4","symbols":["block_buffer::BlockBuffer","block_buffer::Eager","block_buffer::Lazy"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify pkg:cargo/block-buffer@0.10.4",
"kind": "HOW",
"packages": [
"pkg:cargo/block-buffer@0.10.4"
]
}
use block_buffer::generic_array::typenum::U4;
use block_buffer::{BlockBuffer, Eager, Lazy};
fn main() {
// 1. Eager mode: processes full 4-byte blocks immediately when 4th byte arrives
let mut eager_buf = BlockBuffer::<U4, Eager>::default();
let mut eager_blocks: Vec<[u8; 4]> = Vec::new();
eager_buf.digest_blocks(b"abcdefghij", |blocks| {
for block in blocks {
eager_blocks.push((*block).into());
}
});
assert_eq!(eager_blocks, vec![*b"abcd", *b"efgh"]);
assert_eq!(eager_buf.get_pos(), 2);
// Feed 2 more bytes ("kl"): Eager mode processes the 3rd block immediately
eager_buf.digest_blocks(b"kl", |blocks| {
for block in blocks {
eager_blocks.push((*block).into());
}
});
assert_eq!(eager_blocks, vec![*b"abcd", *b"efgh", *b"ijkl"]);
assert_eq!(eager_buf.get_pos(), 0);
// Feed 1 byte and pad remaining bytes with zeros
eager_buf.digest_blocks(b"z", |_| unreachable!());
assert_eq!(eager_buf.get_pos(), 1);
let padded_arr: [u8; 4] = (*eager_buf.pad_with_zeros()).into();
assert_eq!(padded_arr, [b'z', 0, 0, 0]);
assert_eq!(eager_buf.get_pos(), 0);
// 2. Lazy mode: keeps a full block buffered until at least 1 additional byte arrives
let mut lazy_buf = BlockBuffer::<U4, Lazy>::default();
let mut lazy_blocks: Vec<[u8; 4]> = Vec::new();
// Feeding 4 bytes in Lazy mode keeps them in the buffer (pos == 4)
lazy_buf.digest_blocks(b"1234", |blocks| {
for block in blocks {
lazy_blocks.push((*block).into());
}
});
assert!(lazy_blocks.is_empty());
assert_eq!(lazy_buf.get_pos(), 4);
// Feeding 1 more byte triggers processing of the buffered block "1234"
lazy_buf.digest_blocks(b"5", |blocks| {
for block in blocks {
lazy_blocks.push((*block).into());
}
});
assert_eq!(lazy_blocks, vec![*b"1234"]);
assert_eq!(lazy_buf.get_pos(), 1);
let lazy_padded: [u8; 4] = (*lazy_buf.pad_with_zeros()).into();
assert_eq!(lazy_padded, [b'5', 0, 0, 0]);
}
use block_buffer::generic_array::typenum::U4;
use block_buffer::{BlockBuffer, Eager, Lazy};
#[test]
fn contract_block_buffer_eager_and_lazy() {
let mut eager_buf = BlockBuffer::<U4, Eager>::default();
let mut eager_blocks: Vec<[u8; 4]> = Vec::new();
eager_buf.digest_blocks(b"abcdefgh", |blocks| {
for b in blocks {
eager_blocks.push((*b).into());
}
});
assert_eq!(eager_blocks, vec![*b"abcd", *b"efgh"]);
assert_eq!(eager_buf.get_pos(), 0);
let mut lazy_buf = BlockBuffer::<U4, Lazy>::default();
let mut lazy_blocks: Vec<[u8; 4]> = Vec::new();
lazy_buf.digest_blocks(b"abcdefgh", |blocks| {
for b in blocks {
lazy_blocks.push((*b).into());
}
});
assert_eq!(lazy_blocks, vec![*b"abcd"]);
assert_eq!(lazy_buf.get_pos(), 4);
}
오리진 시더
익명