The core trait that all Neuron-Bridge modules must implement.
pub trait Module: Send + Sync {
/// Unique identifier. Used as module_id in BridgeCommand::ExecuteCompute.
fn id(&self) -> &'static str;
/// Human-readable name for display.
fn name(&self) -> &'static str;
/// Execute compute logic.
///
/// # Arguments
/// * `payload` - Raw bytes from the client (module-specific format)
///
/// # Returns
/// * `Ok(Vec<u8>)` - Result bytes sent back to client
/// * `Err(String)` - Error message sent as BridgeResponse::Error
fn process(&self, payload: &[u8]) -> Result<Vec<u8>, String>;
}Send + Sync— modules are shared across async tasks viaArcid()must return a unique, stable stringprocess()should validate input early and return descriptive errors
Factory function type for lazy module instantiation:
pub type ModuleCreator = fn() -> Box<dyn Module>;Convenience function for bulk registration:
pub fn load_all(
registry: &mut HashMap<&'static str, Box<dyn Module>>,
providers: &[(&'static str, ModuleCreator)],
);Every module crate must expose two public symbols for the build system:
pub const MODULE_ID: &str = "my-module";
pub const NEURON_MODULE: ModuleCreator = || -> Box<dyn Module> { Box::new(MyModule) };The server's build.rs scans module/ directories and generates code that references these symbols.
[package]
name = "my-module"
version = "0.1.0"
edition = "2024"
[lib]
crate-type = ["lib"]
[dependencies]
neuron-module-sdk = { git = "https://github.com/EAISD/neuron-module-sdk.git" }
ash = "0.37" # Optional — for Vulkan GPU compute