CodeSampleX

示例

wasm-bindgen-shared 0.2.127

已验证示例 — cargo wasm-bindgen-shared 0.2.127. contract 在 rust 1 · linux alpine/x64 · docker 上运行并通过: SCHEMA_VERSION specifies the shared protocol version string

sha256:5f1419f810e357dc1d0b37df02b651708150e0177832f82b1dd63a5f3ab9c7e3

本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。 提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。 MIT-0

执行证据

声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。

证据依据
签名契约通过
验证回执
1
构建过它的签名密钥
1
声明的环境 linux · alpine · musl 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-19

案例

HOW
目标
verify pkg:cargo/wasm-bindgen-shared@0.2.127
包
创建时间
2026-09-19T04:33:57Z

契约

  1. SCHEMA_VERSION specifies the shared protocol version string
  2. version returns the crate package version string
  3. qualified_name disambiguates JavaScript names with namespaces joined by double underscores
  4. symbol naming helpers construct standardized wasm-bindgen export and helper names
  5. escape_string escapes special characters in strings
  6. identifier module validates and normalizes JavaScript identifiers
  7. tys module provides constant type discriminator identifiers

文件

  • 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 = "sample-wasm-bindgen-shared"
version = "1.0.0"
dependencies = [
 "wasm-bindgen-shared",
]

[[package]]
name = "unicode-ident"
version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"

[[package]]
name = "wasm-bindgen-shared"
version = "0.2.127"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ef64dbcc55df09c7e5a46182d181c2cfa3e925f3da937ea764728b4bbb9dcbf"
dependencies = [
 "unicode-ident",
]
Cargo.toml
[package]
name = "sample-wasm-bindgen-shared"
version = "1.0.0"
edition = "2021"
publish = false

[dependencies]
wasm-bindgen-shared = "=0.2.127"

[[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/wasm-bindgen-shared@0.2.127
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/wasm-bindgen-shared@0.2.127
Required runtime conditions:
  - ecosystem: golang
  - language: go
  - packageManager: go@1.26.6
  - runtime: go@1.26.6

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:38a4c568d06f261e40fb4afece22034a7ff06f4c86a22b68459771bd53063315","contract":["SCHEMA_VERSION specifies the shared protocol version string","version returns the crate package version string","qualified_name disambiguates JavaScript names with namespaces joined by double underscores","symbol naming helpers construct standardized wasm-bindgen export and helper names","escape_string escapes special characters in strings","identifier module validates and normalizes JavaScript identifiers","tys module provides constant type discriminator identifiers"],"goal":"verify pkg:cargo/wasm-bindgen-shared@0.2.127","kind":"HOW","packages":["pkg:cargo/wasm-bindgen-shared@0.2.127"],"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/wasm-bindgen-shared@0.2.127"],"schemaVersion":1,"subject":"pkg:cargo/wasm-bindgen-shared@0.2.127","verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:cargo/wasm-bindgen-shared@0.2.127",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/wasm-bindgen-shared@0.2.127"
  ]
}
src/lib.rs
//! Clean-room verification sample for wasm-bindgen-shared.

pub use wasm_bindgen_shared::*;
test/contract.rs
use wasm_bindgen_shared::{
    dynamic_union_variant, escape_string, free_function, free_function_export_name,
    identifier, new_function, qualified_name, struct_field_get, struct_field_set,
    struct_function_export_name, tys, unwrap_function, upcast_function, version,
    SCHEMA_VERSION,
};

fn main() {
    // 1. SCHEMA_VERSION specifies the shared protocol version string
    assert_eq!(SCHEMA_VERSION, "0.2.122");

    // 2. version returns the crate package version string
    let ver = version();
    assert!(ver.starts_with("0.2.127"));

    // 3. qualified_name disambiguates JavaScript names with namespaces joined by double underscores
    let ns = ["window", "document"];
    assert_eq!(qualified_name(Some(&ns), "body"), "window__document__body");
    let no_ns: Option<&[&str]> = None;
    assert_eq!(qualified_name(no_ns, "alert"), "alert");
    let empty_ns: [&str; 0] = [];
    assert_eq!(qualified_name(Some(&empty_ns), "alert"), "alert");

    // 4. symbol naming helpers construct standardized wasm-bindgen export and helper names
    assert_eq!(new_function("MyClass"), "__wbg_myclass_new");
    assert_eq!(free_function("MyClass"), "__wbg_myclass_free");
    assert_eq!(unwrap_function("MyClass"), "__wbg_myclass_unwrap");
    assert_eq!(upcast_function("Child", "Parent"), "__wbg_upcast_child_to_parent");
    assert_eq!(struct_field_get("MyClass", "field"), "__wbg_get_myclass_field");
    assert_eq!(struct_field_set("MyClass", "field"), "__wbg_set_myclass_field");
    assert_eq!(free_function_export_name("my_fn"), "my_fn");
    assert_eq!(struct_function_export_name("MyClass", "method"), "myclass_method");
    assert_eq!(dynamic_union_variant("MyUnion", 2), "__wbg_dynamic_union_myunion_2");

    // 5. escape_string escapes special characters in strings
    assert_eq!(escape_string("hello\n\"world\"\\"), "hello\\n\\\"world\\\"\\\\");
    assert_eq!(escape_string("test\r'string'"), "test\\r\\'string\\'");

    // 6. identifier module validates and normalizes JavaScript identifiers
    assert!(identifier::is_js_keyword("function"));
    assert!(identifier::is_js_keyword("class"));
    assert!(!identifier::is_js_keyword("custom_identifier"));

    assert!(identifier::is_non_value_js_keyword("let"));
    assert!(!identifier::is_non_value_js_keyword("this"));

    assert!(identifier::is_valid_ident("valid_name$1"));
    assert!(!identifier::is_valid_ident("123invalid"));
    assert!(!identifier::is_valid_ident("invalid-kebab"));

    assert_eq!(identifier::to_valid_ident("valid_name"), "valid_name");
    assert_eq!(identifier::to_valid_ident("invalid-name"), "invalid_name");
    assert_eq!(identifier::to_valid_ident("default"), "_default");

    // 7. tys module provides constant type discriminator identifiers
    assert_eq!(tys::I8, 0);
    assert_eq!(tys::U8, 1);
    assert_eq!(tys::I16, 2);
    assert_eq!(tys::U16, 3);
    assert_eq!(tys::I32, 4);
    assert_eq!(tys::U32, 5);
    assert_eq!(tys::BOOLEAN, 14);
    assert_eq!(tys::STRING, 18);

    println!("All wasm-bindgen-shared contract assertions passed successfully.");
}

原始种子者

匿名