Compare commits
No commits in common. "main" and "v0.1.2" have entirely different histories.
17 changed files with 72 additions and 72 deletions
42
Cargo.lock
generated
42
Cargo.lock
generated
|
|
@ -41,27 +41,6 @@ version = "1.0.4"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
||||
|
||||
[[package]]
|
||||
name = "chain-module-sdk"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"chain-module-sdk-macros",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"thiserror",
|
||||
"wit-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "chain-module-sdk-macros"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.2.17"
|
||||
|
|
@ -97,6 +76,27 @@ version = "1.0.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
||||
|
||||
[[package]]
|
||||
name = "fai-module-sdk"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"fai-module-sdk-macros",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"thiserror",
|
||||
"wit-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fai-module-sdk-macros"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.7"
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
[workspace]
|
||||
resolver = "2"
|
||||
members = [
|
||||
"crates/chain-module-sdk",
|
||||
"crates/chain-module-sdk-macros",
|
||||
"crates/fai-module-sdk",
|
||||
"crates/fai-module-sdk-macros",
|
||||
]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.1.2"
|
||||
edition = "2024"
|
||||
authors = ["Dr. Stefan Flemming <chain@flemming.ai>"]
|
||||
authors = ["Dr. Stefan Flemming <platform@flemming.ai>"]
|
||||
license = "Apache-2.0"
|
||||
repository = "https://git.flemming.ai/fai/module-sdk-rust"
|
||||
repository = "https://git.flemming.ws/fai/module-sdk"
|
||||
homepage = "https://flemming.ai/"
|
||||
rust-version = "1.85"
|
||||
|
||||
|
|
|
|||
2
NOTICE
2
NOTICE
|
|
@ -4,7 +4,7 @@ Copyright 2026 Flemming.AI
|
|||
This product includes software developed by Dr. Stefan Flemming
|
||||
and contributors (https://flemming.ai/).
|
||||
|
||||
This SDK ships a copy of the WIT contract owned by Ch∆In
|
||||
This SDK ships a copy of the WIT contract owned by F∆I Platform
|
||||
(`fai/platform`, frozen at v1.0). The mirror is verified by a
|
||||
SHA-256 snapshot test and updated only in lockstep with the
|
||||
upstream contract.
|
||||
|
|
|
|||
10
README.md
10
README.md
|
|
@ -1,6 +1,6 @@
|
|||
# fai-module-sdk
|
||||
|
||||
Stable, ergonomic Rust surface for writing Ch∆In modules.
|
||||
Stable, ergonomic Rust surface for writing F∆I Platform modules.
|
||||
|
||||
A module written against this crate looks like:
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ That single function — plus a `Cargo.toml` listing
|
|||
## Stability
|
||||
|
||||
The SDK insulates module code from the underlying WIT contract
|
||||
(`chain:platform`, frozen at v1.0 in the platform repo). The
|
||||
(`fai:platform`, frozen at v1.0 in the platform repo). The
|
||||
WIT may evolve in additive minor versions or, eventually, a
|
||||
coordinated v2.0; the SDK absorbs that change so existing
|
||||
module code keeps compiling.
|
||||
|
|
@ -47,7 +47,7 @@ two ever drift, CI fails.
|
|||
|
||||
| Track | Stability |
|
||||
|-------|-----------|
|
||||
| WIT contract (`chain:platform`) | Frozen at v1.0 in the platform repo |
|
||||
| WIT contract (`fai:platform`) | Frozen at v1.0 in the platform repo |
|
||||
| `fai-module-sdk` Rust API | Semver; v0.x while ergonomics evolve |
|
||||
| Per-module versions | Each module repo's own concern |
|
||||
|
||||
|
|
@ -55,5 +55,5 @@ two ever drift, CI fails.
|
|||
|
||||
Apache-2.0. See `LICENSE`.
|
||||
|
||||
Author: Dr. Stefan Flemming, Flemming.AI <chain@flemming.ai>
|
||||
Repository: https://git.flemming.ai/fai/module-sdk-rust
|
||||
Author: Dr. Stefan Flemming, Flemming.AI <platform@flemming.ai>
|
||||
Repository: https://git.flemming.ws/fai/module-sdk
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "chain-module-sdk-macros"
|
||||
name = "fai-module-sdk-macros"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
authors.workspace = true
|
||||
|
|
@ -7,7 +7,7 @@ license.workspace = true
|
|||
repository.workspace = true
|
||||
homepage.workspace = true
|
||||
rust-version.workspace = true
|
||||
description = "Procedural macros for chain-module-sdk. Not used directly — see chain-module-sdk."
|
||||
description = "Procedural macros for fai-module-sdk. Not used directly — see fai-module-sdk."
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
//! Procedural macros powering `chain-module-sdk`.
|
||||
//! Procedural macros powering `fai-module-sdk`.
|
||||
//!
|
||||
//! This crate exists only to host the `#[fai_module]` attribute.
|
||||
//! Module authors should depend on `chain-module-sdk` (which
|
||||
//! Module authors should depend on `fai-module-sdk` (which
|
||||
//! re-exports the macro), not on this crate directly.
|
||||
|
||||
use proc_macro::TokenStream;
|
||||
|
|
@ -51,14 +51,14 @@ pub fn fai_module(_attrs: TokenStream, input: TokenStream) -> TokenStream {
|
|||
clippy::nursery
|
||||
)]
|
||||
|
||||
::chain_module_sdk::__rt::wit_bindgen::generate!({
|
||||
::fai_module_sdk::__rt::wit_bindgen::generate!({
|
||||
inline: #wit_literal,
|
||||
world: "module",
|
||||
runtime_path: "::chain_module_sdk::__rt::wit_bindgen::rt",
|
||||
runtime_path: "::fai_module_sdk::__rt::wit_bindgen::rt",
|
||||
});
|
||||
|
||||
use exports::chain::platform::invoke::Guest;
|
||||
use chain::platform::types::{
|
||||
use exports::fai::platform::invoke::Guest;
|
||||
use fai::platform::types::{
|
||||
BytesValue as WitBytes,
|
||||
FileRef as WitFileRef,
|
||||
InvocationContext as WitContext,
|
||||
|
|
@ -79,7 +79,7 @@ pub fn fai_module(_attrs: TokenStream, input: TokenStream) -> TokenStream {
|
|||
::std::vec::Vec<(::std::string::String, WitPayload)>,
|
||||
WitError,
|
||||
> {
|
||||
let sdk_ctx = ::chain_module_sdk::Context {
|
||||
let sdk_ctx = ::fai_module_sdk::Context {
|
||||
invocation_id: ctx.invocation_id,
|
||||
capability_namespace: ctx.capability_namespace,
|
||||
capability_name: ctx.capability_name,
|
||||
|
|
@ -87,13 +87,13 @@ pub fn fai_module(_attrs: TokenStream, input: TokenStream) -> TokenStream {
|
|||
};
|
||||
let sdk_pairs: ::std::vec::Vec<(
|
||||
::std::string::String,
|
||||
::chain_module_sdk::Payload,
|
||||
::fai_module_sdk::Payload,
|
||||
)> = inputs
|
||||
.into_iter()
|
||||
.map(|(k, p)| (k, wit_payload_to_sdk(p)))
|
||||
.collect();
|
||||
let sdk_inputs =
|
||||
::chain_module_sdk::Inputs::__from_pairs(sdk_pairs);
|
||||
::fai_module_sdk::Inputs::__from_pairs(sdk_pairs);
|
||||
|
||||
match super::#user_fn_name(sdk_ctx, sdk_inputs) {
|
||||
Ok(outputs) => {
|
||||
|
|
@ -109,18 +109,18 @@ pub fn fai_module(_attrs: TokenStream, input: TokenStream) -> TokenStream {
|
|||
}
|
||||
}
|
||||
|
||||
fn wit_payload_to_sdk(p: WitPayload) -> ::chain_module_sdk::Payload {
|
||||
fn wit_payload_to_sdk(p: WitPayload) -> ::fai_module_sdk::Payload {
|
||||
match p {
|
||||
WitPayload::Text(s) => ::chain_module_sdk::Payload::Text(s),
|
||||
WitPayload::Json(s) => ::chain_module_sdk::Payload::Json(s),
|
||||
WitPayload::Bytes(b) => ::chain_module_sdk::Payload::Bytes(
|
||||
::chain_module_sdk::BytesValue {
|
||||
WitPayload::Text(s) => ::fai_module_sdk::Payload::Text(s),
|
||||
WitPayload::Json(s) => ::fai_module_sdk::Payload::Json(s),
|
||||
WitPayload::Bytes(b) => ::fai_module_sdk::Payload::Bytes(
|
||||
::fai_module_sdk::BytesValue {
|
||||
mime_type: b.mime_type,
|
||||
data: b.data,
|
||||
},
|
||||
),
|
||||
WitPayload::FileRef(f) => ::chain_module_sdk::Payload::FileRef(
|
||||
::chain_module_sdk::FileRef {
|
||||
WitPayload::FileRef(f) => ::fai_module_sdk::Payload::FileRef(
|
||||
::fai_module_sdk::FileRef {
|
||||
uri: f.uri,
|
||||
mime_type: f.mime_type,
|
||||
size_bytes: f.size_bytes,
|
||||
|
|
@ -130,15 +130,15 @@ pub fn fai_module(_attrs: TokenStream, input: TokenStream) -> TokenStream {
|
|||
}
|
||||
}
|
||||
|
||||
fn sdk_payload_to_wit(p: ::chain_module_sdk::Payload) -> WitPayload {
|
||||
fn sdk_payload_to_wit(p: ::fai_module_sdk::Payload) -> WitPayload {
|
||||
match p {
|
||||
::chain_module_sdk::Payload::Text(s) => WitPayload::Text(s),
|
||||
::chain_module_sdk::Payload::Json(s) => WitPayload::Json(s),
|
||||
::chain_module_sdk::Payload::Bytes(b) => WitPayload::Bytes(WitBytes {
|
||||
::fai_module_sdk::Payload::Text(s) => WitPayload::Text(s),
|
||||
::fai_module_sdk::Payload::Json(s) => WitPayload::Json(s),
|
||||
::fai_module_sdk::Payload::Bytes(b) => WitPayload::Bytes(WitBytes {
|
||||
mime_type: b.mime_type,
|
||||
data: b.data,
|
||||
}),
|
||||
::chain_module_sdk::Payload::FileRef(f) => WitPayload::FileRef(WitFileRef {
|
||||
::fai_module_sdk::Payload::FileRef(f) => WitPayload::FileRef(WitFileRef {
|
||||
uri: f.uri,
|
||||
mime_type: f.mime_type,
|
||||
size_bytes: f.size_bytes,
|
||||
|
|
@ -147,21 +147,21 @@ pub fn fai_module(_attrs: TokenStream, input: TokenStream) -> TokenStream {
|
|||
}
|
||||
}
|
||||
|
||||
fn sdk_error_to_wit(e: ::chain_module_sdk::ModuleError) -> WitError {
|
||||
fn sdk_error_to_wit(e: ::fai_module_sdk::ModuleError) -> WitError {
|
||||
match e {
|
||||
::chain_module_sdk::ModuleError::InvalidInput(s) => {
|
||||
::fai_module_sdk::ModuleError::InvalidInput(s) => {
|
||||
WitError::InvalidInput(s)
|
||||
}
|
||||
::chain_module_sdk::ModuleError::PermissionDenied(s) => {
|
||||
::fai_module_sdk::ModuleError::PermissionDenied(s) => {
|
||||
WitError::PermissionDenied(s)
|
||||
}
|
||||
::chain_module_sdk::ModuleError::ResourceExhausted(s) => {
|
||||
::fai_module_sdk::ModuleError::ResourceExhausted(s) => {
|
||||
WitError::ResourceExhausted(s)
|
||||
}
|
||||
::chain_module_sdk::ModuleError::DeadlineExceeded => {
|
||||
::fai_module_sdk::ModuleError::DeadlineExceeded => {
|
||||
WitError::DeadlineExceeded
|
||||
}
|
||||
::chain_module_sdk::ModuleError::Internal(s) => WitError::Internal(s),
|
||||
::fai_module_sdk::ModuleError::Internal(s) => WitError::Internal(s),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "chain-module-sdk"
|
||||
name = "fai-module-sdk"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
authors.workspace = true
|
||||
|
|
@ -7,10 +7,10 @@ license.workspace = true
|
|||
repository.workspace = true
|
||||
homepage.workspace = true
|
||||
rust-version.workspace = true
|
||||
description = "Stable, ergonomic surface for writing Ch∆In modules in Rust"
|
||||
description = "Stable, ergonomic surface for writing F∆I Platform modules in Rust"
|
||||
|
||||
[dependencies]
|
||||
chain-module-sdk-macros = { path = "../chain-module-sdk-macros" }
|
||||
fai-module-sdk-macros = { path = "../fai-module-sdk-macros" }
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
//! Ergonomic Rust surface for writing Ch∆In modules.
|
||||
//! Ergonomic Rust surface for writing F∆I Platform modules.
|
||||
//!
|
||||
//! A module written against this crate looks like:
|
||||
//!
|
||||
//! ```ignore
|
||||
//! use chain_module_sdk::prelude::*;
|
||||
//! use fai_module_sdk::prelude::*;
|
||||
//!
|
||||
//! #[fai_module]
|
||||
//! fn invoke(_ctx: Context, inputs: Inputs) -> Result<Outputs, ModuleError> {
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
//! # Stability
|
||||
//!
|
||||
//! This crate insulates modules from the underlying WIT contract
|
||||
//! (`chain:platform`, frozen at v1.0). The WIT may evolve in additive
|
||||
//! (`fai:platform`, frozen at v1.0). The WIT may evolve in additive
|
||||
//! minor versions or, eventually, a coordinated v2.0; the SDK absorbs
|
||||
//! that change so module code keeps compiling.
|
||||
|
||||
|
|
@ -35,9 +35,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 fai_module_sdk_macros::fai_module;
|
||||
|
||||
/// Convenience prelude — `use chain_module_sdk::prelude::*;` brings
|
||||
/// Convenience prelude — `use fai_module_sdk::prelude::*;` brings
|
||||
/// every type a typical module needs into scope.
|
||||
pub mod prelude {
|
||||
pub use super::{
|
||||
|
|
@ -10,13 +10,13 @@ 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 an F∆I module with fai-module-sdk."
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
chain-module-sdk = { path = "../../crates/chain-module-sdk" }
|
||||
fai-module-sdk = { path = "../../crates/fai-module-sdk" }
|
||||
|
||||
[profile.release]
|
||||
opt-level = "s"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
//! `unsafe_op_in_unsafe_fn` allow, no `export!` call, no manual
|
||||
//! Payload-variant matching.
|
||||
|
||||
use chain_module_sdk::prelude::*;
|
||||
use fai_module_sdk::prelude::*;
|
||||
|
||||
#[fai_module]
|
||||
fn invoke(_ctx: Context, inputs: Inputs) -> Result<Outputs, ModuleError> {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
// stable, ergonomic surface. That is what protects modules
|
||||
// from any future evolution of this contract.
|
||||
|
||||
package chain:platform@1.0.0;
|
||||
package fai:platform@1.0.0;
|
||||
|
||||
/// Types that flow between the host (hub) and modules.
|
||||
interface types {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue