chore: finish fai->chain naming in README, repository URL, macro internals
Some checks failed
CI / Linux x86_64 (Forgejo) (push) Failing after 1s
Some checks failed
CI / Linux x86_64 (Forgejo) (push) Failing after 1s
README still documented the crate as fai-module-sdk with a fai_module_sdk::prelude import; the workspace repository field pointed at the pre-rename module-sdk-rust URL; the #[fai_module] expansion used a __fai_module_sdk_internal hygiene module. All three now carry the chain-module-sdk name. Also note the WIT contract is chain:platform@1.1 (additive emit-event on the frozen 1.0 base) and document ctx.emit in the surface table. Signed-off-by: flemming-it <sf@flemming.it>
This commit is contained in:
parent
f32dc820b9
commit
5cbdb5324e
3 changed files with 14 additions and 13 deletions
|
|
@ -10,7 +10,7 @@ version = "0.1.2"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
authors = ["Dr. Stefan Flemming <chain@flemming.ai>"]
|
authors = ["Dr. Stefan Flemming <chain@flemming.ai>"]
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
repository = "https://git.flemming.ai/fai/module-sdk-rust"
|
repository = "https://git.flemming.ai/fai/chain-module-sdk-rust"
|
||||||
homepage = "https://flemming.ai/"
|
homepage = "https://flemming.ai/"
|
||||||
rust-version = "1.85"
|
rust-version = "1.85"
|
||||||
|
|
||||||
|
|
|
||||||
23
README.md
23
README.md
|
|
@ -1,11 +1,11 @@
|
||||||
# fai-module-sdk
|
# chain-module-sdk
|
||||||
|
|
||||||
Stable, ergonomic Rust surface for writing Ch∆In modules.
|
Stable, ergonomic Rust surface for writing Ch∆In modules.
|
||||||
|
|
||||||
A module written against this crate looks like:
|
A module written against this crate looks like:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use fai_module_sdk::prelude::*;
|
use chain_module_sdk::prelude::*;
|
||||||
|
|
||||||
#[fai_module]
|
#[fai_module]
|
||||||
fn invoke(_ctx: Context, inputs: Inputs) -> Result<Outputs, ModuleError> {
|
fn invoke(_ctx: Context, inputs: Inputs) -> Result<Outputs, ModuleError> {
|
||||||
|
|
@ -15,7 +15,7 @@ fn invoke(_ctx: Context, inputs: Inputs) -> Result<Outputs, ModuleError> {
|
||||||
```
|
```
|
||||||
|
|
||||||
That single function — plus a `Cargo.toml` listing
|
That single function — plus a `Cargo.toml` listing
|
||||||
`fai-module-sdk` as a dependency — is the entire module. The
|
`chain-module-sdk` as a dependency — is the entire module. The
|
||||||
`#[fai_module]` macro generates the `wit_bindgen` invocation, the
|
`#[fai_module]` macro generates the `wit_bindgen` invocation, the
|
||||||
`Guest` implementation, the type conversions, and the
|
`Guest` implementation, the type conversions, and the
|
||||||
`wit_bindgen::export!` glue behind the scenes.
|
`wit_bindgen::export!` glue behind the scenes.
|
||||||
|
|
@ -27,19 +27,20 @@ That single function — plus a `Cargo.toml` listing
|
||||||
| `Inputs::require_text("name")` | manual `match payload { Payload::Text(s) => ..., _ => ... }` |
|
| `Inputs::require_text("name")` | manual `match payload { Payload::Text(s) => ..., _ => ... }` |
|
||||||
| `Outputs::new().with_json(...)?` | building `Vec<(String, Payload)>` by hand |
|
| `Outputs::new().with_json(...)?` | building `Vec<(String, Payload)>` by hand |
|
||||||
| `ModuleError::invalid_input("...")` | constructing WIT `invocation-error` variants |
|
| `ModuleError::invalid_input("...")` | constructing WIT `invocation-error` variants |
|
||||||
|
| `ctx.emit("progress", ...)` | hand-rolling the `host.emit-event` import (WIT 1.1) |
|
||||||
| `#[fai_module]` | `wit_bindgen::generate!` + `Guest` impl + `export!` + `#![allow(unsafe_op_in_unsafe_fn)]` |
|
| `#[fai_module]` | `wit_bindgen::generate!` + `Guest` impl + `export!` + `#![allow(unsafe_op_in_unsafe_fn)]` |
|
||||||
|
|
||||||
## Stability
|
## Stability
|
||||||
|
|
||||||
The SDK insulates module code from the underlying WIT contract
|
The SDK insulates module code from the underlying WIT contract
|
||||||
(`chain:platform`, frozen at v1.0 in the platform repo). The
|
(`chain:platform`, currently v1.1 — frozen base v1.0 plus the
|
||||||
WIT may evolve in additive minor versions or, eventually, a
|
additive 1.1 `emit-event` import). The WIT may evolve in
|
||||||
coordinated v2.0; the SDK absorbs that change so existing
|
additive minor versions or, eventually, a coordinated v2.0; the
|
||||||
module code keeps compiling.
|
SDK absorbs that change so existing module code keeps compiling.
|
||||||
|
|
||||||
The SDK ships its own copy of `wit/world.wit` so that the
|
The SDK ships its own copy of `wit/world.wit` so that the
|
||||||
proc-macro can embed the contract via `include_str!` at compile
|
proc-macro can embed the contract via `include_str!` at compile
|
||||||
time. A snapshot test (`crates/fai-module-sdk/tests/wit_freeze.rs`)
|
time. A snapshot test (`crates/chain-module-sdk/tests/wit_freeze.rs`)
|
||||||
asserts the SHA-256 matches the platform's frozen hash — if the
|
asserts the SHA-256 matches the platform's frozen hash — if the
|
||||||
two ever drift, CI fails.
|
two ever drift, CI fails.
|
||||||
|
|
||||||
|
|
@ -47,8 +48,8 @@ two ever drift, CI fails.
|
||||||
|
|
||||||
| Track | Stability |
|
| Track | Stability |
|
||||||
|-------|-----------|
|
|-------|-----------|
|
||||||
| WIT contract (`chain:platform`) | Frozen at v1.0 in the platform repo |
|
| WIT contract (`chain:platform`) | v1.1; base frozen at v1.0, minors are additive |
|
||||||
| `fai-module-sdk` Rust API | Semver; v0.x while ergonomics evolve |
|
| `chain-module-sdk` Rust API | Semver; v0.x while ergonomics evolve |
|
||||||
| Per-module versions | Each module repo's own concern |
|
| Per-module versions | Each module repo's own concern |
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
@ -56,4 +57,4 @@ two ever drift, CI fails.
|
||||||
Apache-2.0. See `LICENSE`.
|
Apache-2.0. See `LICENSE`.
|
||||||
|
|
||||||
Author: Dr. Stefan Flemming, Flemming.AI <chain@flemming.ai>
|
Author: Dr. Stefan Flemming, Flemming.AI <chain@flemming.ai>
|
||||||
Repository: https://git.flemming.ai/fai/module-sdk-rust
|
Repository: https://git.flemming.ai/fai/chain-module-sdk-rust
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ pub fn fai_module(_attrs: TokenStream, input: TokenStream) -> TokenStream {
|
||||||
// dragging the wit_bindgen runtime onto the host target.
|
// dragging the wit_bindgen runtime onto the host target.
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
mod __fai_module_sdk_internal {
|
mod __chain_module_sdk_internal {
|
||||||
#![allow(
|
#![allow(
|
||||||
unsafe_op_in_unsafe_fn,
|
unsafe_op_in_unsafe_fn,
|
||||||
unused_imports,
|
unused_imports,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue