聯絡我們

联调盒-LIB

Test

函式庫開發者 sijintao20

取得$66/月將在 SignalPlus OS 中開啟,登入後即可安裝。
評分
—
尚無評分
價格
$66/月
版本
1
2026年11月2日
開發者
sijintao20

關於這個函式庫

联调盒 — Library Integration Kit

Version 1.0.0. Deterministic, pure-compute fixtures for testing Library integration in SP2 Module Apps. Check linking, version selection, scalar and array arguments, output pointers, and error handling without market data, credentials, network calls, storage, or orders. This is a developer testing tool, not a trading strategy.

Interface

Target: wasm32-wasip1. C ABI; Rust declarations are shipped in src/lib.rs, C declarations in include/, and machine-readable signatures in abi.json.

fn sp2_01a19b6c_a140_76bf_85af_13acaa274ead_init() -> i32;
fn sp2_01a19b6c_a140_76bf_85af_13acaa274ead_version() -> u32;
fn sp2_01a19b6c_a140_76bf_85af_13acaa274ead_add(a: i32, b: i32) -> i64;
fn sp2_01a19b6c_a140_76bf_85af_13acaa274ead_sum(values: *const i32, len: u32, out: *mut i64) -> i32;
fn sp2_01a19b6c_a140_76bf_85af_13acaa274ead_divide(a: i32, b: i32, out: *mut i32) -> i32;

All bindings are unsafe extern "C" declarations. The public package contains bindings and the prebuilt archive; consumers do not need the private implementation.

Initialization and version

Call sp2_01a19b6c_a140_76bf_85af_13acaa274ead_init() exactly once from the App's initialization path, after platform initialization and before registering work that calls this Library. It returns 0; this version allocates no state. Initialization is an integration contract, not a global-state guard.

sp2_01a19b6c_a140_76bf_85af_13acaa274ead_version() takes no arguments and returns 10000 for 1.0.0: major * 10000 + minor * 100 + patch. This encoding reserves minor and patch values 0..99; changing the encoding requires an ABI compatibility update.

Addition

sp2_01a19b6c_a140_76bf_85af_13acaa274ead_add(a, b) accepts two signed 32-bit integers and returns their exact signed 64-bit sum. Both operands widen before addition; no input pair overflows. No errors or output pointers.

Examples: (2, 3) → 5; (-7, 3) → -4; (2147483647, 2147483647) → 4294967294.

Array sum

sp2_01a19b6c_a140_76bf_85af_13acaa274ead_sum(values, len, out) accepts a pointer to len consecutive signed 32-bit values, a count from 0 to 4096 inclusive, and a pointer to a signed 64-bit output. It returns a status and writes the exact sum only on success. Empty input writes 0; values may be null only when len is 0. At the supported maximum length the sum cannot overflow an i64.

Validation order: null output → status 1; len > 4096 → 2; nonempty null input → 1. Errors never change the output.

Examples: [1, -2, 3, 4] → status 0, output 6; (null, 0, valid_out) → status 0, output 0; (null, 1, valid_out) → status 1; 4097 elements → status 2.

Integer division

sp2_01a19b6c_a140_76bf_85af_13acaa274ead_divide(a, b, out) accepts two signed 32-bit integers and a pointer to a signed 32-bit output. It returns a status and writes a / b, truncating toward zero, only on success. Errors never change the output.

Validation order: null output → status 1; b = 0 → 3; a = -2147483648 and b = -1 → 4 (overflow).

Examples: (7, 2) → status 0, output 3; (-7, 2) → status 0, output -3; (7, 0) → status 3, output unchanged; (-2147483648, -1) → status 4, output unchanged.

Status codes and pointer safety

| Code | Meaning | Used by | | --- | --- | --- | | 0 | Success | init, sum, divide | | 1 | Required pointer is null | sum, divide | | 2 | Array length exceeds 4096 | sum | | 3 | Division by zero | divide | | 4 | Signed division overflow | divide |

version and add return values, not status codes. No hidden defaults.

Non-null pointers must refer to valid, aligned memory in the consuming Wasm instance. Output pointers must be writable for the documented type; nonempty inputs must be readable for the full declared count. Input/output memory regions must not overlap. Null checks do not validate arbitrary non-null addresses. Passing dangling, misaligned, out-of-bounds, or overlapping pointers violates the caller contract. The Library never retains or frees pointers and allocates no memory across the ABI. No String, Vec, or JSON crosses the FFI boundary.

Usage

After the selected version has been released and the current user has entitlement, assignment, and the exact package installed, declare the registry dependency:

[dependencies]
liantiaobox = { package = "sp201a12006f2b8731ca8b471d7552c35f8-01a19b6c-a140-76bf-85af-13acaa274ead-sys", version = "=1.0.0", registry = "sp2-cargo" }

Commit the App's Cargo.lock. The short liantiaobox alias is intentional; do not rename the published package or redeclare its FFI symbols.

use liantiaobox::{
    sp2_01a19b6c_a140_76bf_85af_13acaa274ead_init as library_init,
    sp2_01a19b6c_a140_76bf_85af_13acaa274ead_version as library_version,
    sp2_01a19b6c_a140_76bf_85af_13acaa274ead_add as add,
    sp2_01a19b6c_a140_76bf_85af_13acaa274ead_sum as sum,
    sp2_01a19b6c_a140_76bf_85af_13acaa274ead_divide as divide,
};

// In the existing App init path, after platform initialization (exactly once):
let status = unsafe { library_init() };
// Propagate a nonzero init status as an initialization error.

// In a later test handler; all non-null pointers below are valid local memory:
let linked_version = unsafe { library_version() }; // 10000
let addition = unsafe { add(2, 3) };               // 5
let values = [1, -2, 3, 4];
let mut total = 0_i64;
let sum_status = unsafe { sum(values.as_ptr(), 4, &mut total) }; // 0, total=6
let mut quotient = 99_i32;
let divide_status = unsafe { divide(7, 0, &mut quotient) };     // 3, quotient=99

For UI testing, return each observed result and expected result through the consuming App's own business handler and display pass/fail rows. The Library itself has no page or standalone Preview. If exposing generic i64 results as JSON for JavaScript, encode them as decimal strings when they exceed the safe integer range; these fixtures' documented numeric ranges remain within that range.

Versioning/Compatibility

1.0.0 is the first implemented contract and replaces the unpublished scaffold. All five exported signatures above are the 1.x ABI. Changing/removing a symbol, altering output types or pointer layout, or changing existing return semantics requires a new major version. Compatible additions use a minor version; fixes preserving the contract use a patch version.

Apps pin exact versions. Publishing a new Library version does not modify an already compiled App; update its dependency and rebuild to adopt it.

Pricing/Entitlement

This repository does not set a price or promise public availability. Release scope and any Marketplace listing are managed through the platform. Access is checked dynamically: organization entitlement, current-user assignment, and installation of the exact version are separate requirements. Ownership alone is not proof of usable package access. Entitlement is per Library; released-version price differences and expiry follow the platform's current terms. Do not repurchase to fix missing assignment; an organization Admin must assign access.

Validation

The author repository includes examples/app_checks.rs, which produces 22 named pass/fail results reusable in an App, plus a standalone Wasm consumer. make test builds the actual static archive, links it through this public -sys crate, and executes the consumer under WASI. sp2-verify --profile lib --repo . --json separately checks platform packaging and ABI conformance. Local WASI checks do not claim an installed App or platform registry integration has been tested.

新功能

版本 1 · 2026年11月2日

資訊

開發者
sijintao20
類型
函式庫
價格
$66/月
Remix
不開放 Remix
上架時間
2026年11月2日

同一開發者的更多作品

App 市場中的 App 由獨立開發者製作,上架前經 SignalPlus 審核;介紹文字由開發者提供。本站內容不構成投資建議,也不承諾收益。