diff --git a/Cargo.lock b/Cargo.lock index cc76d83..d419227 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,7 +43,7 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "chain-module-sdk" -version = "0.2.0" +version = "0.3.0" dependencies = [ "chain-module-sdk-macros", "serde", @@ -55,7 +55,7 @@ dependencies = [ [[package]] name = "chain-module-sdk-macros" -version = "0.2.0" +version = "0.3.0" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 6fdd56c..2101c8c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ members = [ ] [workspace.package] -version = "0.2.0" +version = "0.3.0" edition = "2024" authors = ["Dr. Stefan Flemming "] license = "Apache-2.0" diff --git a/README.md b/README.md index 9b3f7bd..b5bc4ca 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A module written against this crate looks like: ```rust use chain_module_sdk::prelude::*; -#[fai_module] +#[chain_module] fn invoke(_ctx: Context, inputs: Inputs) -> Result { let text = inputs.require_text("input")?; Ok(Outputs::new().with_text("output", format!("echo: {text}"))) @@ -16,7 +16,7 @@ fn invoke(_ctx: Context, inputs: Inputs) -> Result { That single function — plus a `Cargo.toml` listing `chain-module-sdk` as a dependency — is the entire module. The -`#[fai_module]` macro generates the `wit_bindgen` invocation, the +`#[chain_module]` macro generates the `wit_bindgen` invocation, the `Guest` implementation, the type conversions, and the `wit_bindgen::export!` glue behind the scenes. @@ -28,7 +28,7 @@ That single function — plus a `Cargo.toml` listing | `Outputs::new().with_json(...)?` | building `Vec<(String, Payload)>` by hand | | `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)]` | +| `#[chain_module]` | `wit_bindgen::generate!` + `Guest` impl + `export!` + `#![allow(unsafe_op_in_unsafe_fn)]` | ## Stability diff --git a/crates/chain-module-sdk-macros/src/lib.rs b/crates/chain-module-sdk-macros/src/lib.rs index 62032e7..e64e49b 100644 --- a/crates/chain-module-sdk-macros/src/lib.rs +++ b/crates/chain-module-sdk-macros/src/lib.rs @@ -1,6 +1,6 @@ //! Procedural macros powering `chain-module-sdk`. //! -//! This crate exists only to host the `#[fai_module]` attribute. +//! This crate exists only to host the `#[chain_module]` attribute. //! Module authors should depend on `chain-module-sdk` (which //! re-exports the macro), not on this crate directly. @@ -26,7 +26,7 @@ const WIT_INLINE: &str = include_str!("../../../wit/world.wit"); /// the `wit_bindgen::export!` call. The function can be named /// anything — only its signature matters. #[proc_macro_attribute] -pub fn fai_module(_attrs: TokenStream, input: TokenStream) -> TokenStream { +pub fn chain_module(_attrs: TokenStream, input: TokenStream) -> TokenStream { let user_fn = parse_macro_input!(input as ItemFn); let user_fn_name = user_fn.sig.ident.clone(); let wit_literal = WIT_INLINE; diff --git a/crates/chain-module-sdk/src/context.rs b/crates/chain-module-sdk/src/context.rs index 32080d0..f16a3f5 100644 --- a/crates/chain-module-sdk/src/context.rs +++ b/crates/chain-module-sdk/src/context.rs @@ -1,7 +1,7 @@ //! Invocation context passed to a module on every call. //! //! Mirrors the WIT `invocation-context` record. The -//! `#[fai_module]` macro builds this from the WIT-generated value +//! `#[chain_module]` macro builds this from the WIT-generated value //! before handing it to user code. #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/crates/chain-module-sdk/src/host.rs b/crates/chain-module-sdk/src/host.rs index de9572d..e73579d 100644 --- a/crates/chain-module-sdk/src/host.rs +++ b/crates/chain-module-sdk/src/host.rs @@ -1,7 +1,7 @@ //! Host-callback plumbing for `Context::emit` (WIT 1.1 `emit-event`). //! //! The WIT host imports (`emit-event`) are only reachable from the -//! `wit_bindgen`-generated glue inside the `#[fai_module]` expansion, +//! `wit_bindgen`-generated glue inside the `#[chain_module]` expansion, //! which lives in the module crate — not here. So the macro installs a //! function pointer that reaches the real host import, and //! [`Context::emit`](crate::Context::emit) calls it through this hook. @@ -18,7 +18,7 @@ thread_local! { static EMIT_HOOK: Cell> = const { Cell::new(None) }; } -/// Install the emit hook. Called by the `#[fai_module]` expansion at +/// Install the emit hook. Called by the `#[chain_module]` expansion at /// the start of each invocation. Not part of the stable public API. #[doc(hidden)] pub fn __set_emit_hook(f: fn(&str, Payload)) { diff --git a/crates/chain-module-sdk/src/inputs.rs b/crates/chain-module-sdk/src/inputs.rs index 9f8b46e..ea1cc54 100644 --- a/crates/chain-module-sdk/src/inputs.rs +++ b/crates/chain-module-sdk/src/inputs.rs @@ -19,7 +19,7 @@ pub struct Inputs { impl Inputs { /// Build directly from a list of `(name, payload)` pairs. - /// Used by the `#[fai_module]` macro after WIT conversion. + /// Used by the `#[chain_module]` macro after WIT conversion. #[doc(hidden)] pub fn __from_pairs(items: Vec<(String, Payload)>) -> Self { Self { items } diff --git a/crates/chain-module-sdk/src/lib.rs b/crates/chain-module-sdk/src/lib.rs index 88ff172..d059f63 100644 --- a/crates/chain-module-sdk/src/lib.rs +++ b/crates/chain-module-sdk/src/lib.rs @@ -5,7 +5,7 @@ //! ```ignore //! use chain_module_sdk::prelude::*; //! -//! #[fai_module] +//! #[chain_module] //! fn invoke(_ctx: Context, inputs: Inputs) -> Result { //! let text = inputs.require_text("input")?; //! Ok(Outputs::new().with_text("output", format!("got: {text}"))) @@ -36,9 +36,9 @@ pub use inputs::Inputs; pub use outputs::Outputs; pub use payload::{BytesValue, FileRef, Payload}; -pub use chain_module_sdk_macros::fai_module; +pub use chain_module_sdk_macros::chain_module; -// Emit-hook plumbing used by the `#[fai_module]` expansion (wasm32) +// Emit-hook plumbing used by the `#[chain_module]` expansion (wasm32) // so `Context::emit` reaches the WIT `emit-event` host import. #[doc(hidden)] pub use host::__set_emit_hook; @@ -48,11 +48,11 @@ pub(crate) use host::emit; /// every type a typical module needs into scope. pub mod prelude { pub use super::{ - BytesValue, Context, FileRef, Inputs, ModuleError, Outputs, Payload, fai_module, + BytesValue, Context, FileRef, Inputs, ModuleError, Outputs, Payload, chain_module, }; } -/// Internal re-exports the `#[fai_module]` macro expansion depends on. +/// Internal re-exports the `#[chain_module]` macro expansion depends on. /// /// Not part of the public API. Anything in this module may change /// between SDK patch releases. diff --git a/crates/chain-module-sdk/src/outputs.rs b/crates/chain-module-sdk/src/outputs.rs index 3ac21d8..037f350 100644 --- a/crates/chain-module-sdk/src/outputs.rs +++ b/crates/chain-module-sdk/src/outputs.rs @@ -71,7 +71,7 @@ impl Outputs { } /// Consume the builder into the underlying `(name, payload)` list. - /// Used by the `#[fai_module]` macro after WIT conversion. + /// Used by the `#[chain_module]` macro after WIT conversion. #[doc(hidden)] pub fn __into_pairs(self) -> Vec<(String, Payload)> { self.items diff --git a/crates/chain-module-sdk/src/payload.rs b/crates/chain-module-sdk/src/payload.rs index 4a87c2e..8016bf0 100644 --- a/crates/chain-module-sdk/src/payload.rs +++ b/crates/chain-module-sdk/src/payload.rs @@ -2,7 +2,7 @@ //! //! The shape is fixed by the v1.0 WIT freeze. Field-by-field //! conversion to and from the WIT-generated type happens inside -//! the `#[fai_module]` macro expansion in the user crate. +//! the `#[chain_module]` macro expansion in the user crate. use serde::{Deserialize, Serialize}; diff --git a/examples/echo/Cargo.lock b/examples/echo/Cargo.lock index 9fa9f77..a7b3f0a 100644 --- a/examples/echo/Cargo.lock +++ b/examples/echo/Cargo.lock @@ -34,7 +34,7 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "chain-module-sdk" -version = "0.1.2" +version = "0.2.1" dependencies = [ "chain-module-sdk-macros", "serde", @@ -45,7 +45,7 @@ dependencies = [ [[package]] name = "chain-module-sdk-macros" -version = "0.1.2" +version = "0.2.1" dependencies = [ "proc-macro2", "quote", diff --git a/examples/echo/Cargo.toml b/examples/echo/Cargo.toml index da76171..7ec5300 100644 --- a/examples/echo/Cargo.toml +++ b/examples/echo/Cargo.toml @@ -10,7 +10,7 @@ version = "0.1.0" edition = "2024" license = "Apache-2.0" publish = false -description = "Reference module showing the minimum needed to write an F∆I module with chain-module-sdk." +description = "Reference module showing the minimum needed to write a Ch∆In module with chain-module-sdk." [lib] crate-type = ["cdylib"] diff --git a/examples/echo/src/lib.rs b/examples/echo/src/lib.rs index b85330e..e538232 100644 --- a/examples/echo/src/lib.rs +++ b/examples/echo/src/lib.rs @@ -1,13 +1,13 @@ -//! Minimum-viable F∆I module — echoes the first text input. +//! Minimum-viable Ch∆In module — echoes the first text input. //! //! Demonstrates the entire authoring surface: a single function -//! decorated with `#[fai_module]`. No `wit_bindgen`, no +//! decorated with `#[chain_module]`. No `wit_bindgen`, no //! `unsafe_op_in_unsafe_fn` allow, no `export!` call, no manual //! Payload-variant matching. use chain_module_sdk::prelude::*; -#[fai_module] +#[chain_module] fn invoke(_ctx: Context, inputs: Inputs) -> Result { let text = inputs.require_text("input")?; Ok(Outputs::new().with_text("output", format!("echo: {text}"))) diff --git a/examples/progress/Cargo.lock b/examples/progress/Cargo.lock index 5282f1f..19c18a7 100644 --- a/examples/progress/Cargo.lock +++ b/examples/progress/Cargo.lock @@ -34,7 +34,7 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "chain-module-sdk" -version = "0.1.2" +version = "0.3.0" dependencies = [ "chain-module-sdk-macros", "serde", @@ -45,7 +45,7 @@ dependencies = [ [[package]] name = "chain-module-sdk-macros" -version = "0.1.2" +version = "0.3.0" dependencies = [ "proc-macro2", "quote", diff --git a/examples/progress/src/lib.rs b/examples/progress/src/lib.rs index b222155..c034c9b 100644 --- a/examples/progress/src/lib.rs +++ b/examples/progress/src/lib.rs @@ -6,7 +6,7 @@ use chain_module_sdk::prelude::*; -#[fai_module] +#[chain_module] fn invoke(ctx: Context, inputs: Inputs) -> Result { let text = inputs.require_text("input")?;