API Reference
This section documents the public Rust API for the NTL runtime library.
The API is under active development and subject to breaking changes until v1.0.0.
Crate Structure
ntl
├── ntl::node // Node initialization and management
├── ntl::signal // Signal creation, encoding, and types
├── ntl::synapse // Synapse management and configuration
├── ntl::propagation // Propagation engine and scopes
├── ntl::activation // Activation model and functions
├── ntl::crypto // Pluggable cryptographic modules
├── ntl::adapter // Adapter trait and built-in adapters
├── ntl::siafu // SiafuDB integration
├── ntl::config // Configuration loading
└── ntl::testing // Test utilities and mocks
Quick Reference
Creating a Node
use ntl::Node;
let node = Node::builder()
.with_config_file("config.toml")
.with_crypto_module("pq-v1")
.build()
.await?;
Emitting Signals
use ntl::{Signal, SignalType};
let signal = Signal::data("user-created")
.with_payload(serde_json::json!({"user_id": "abc123"}))
.with_weight(0.7)
.with_tags(vec!["user", "event"])
.emit(&node)
.await?;
Handling Signals
use ntl::SignalHandler;
struct MyHandler;
impl SignalHandler for MyHandler {
fn signal_type(&self) -> SignalType { SignalType::Event }
fn tags(&self) -> Vec<&str> { vec!["user"] }
async fn handle(&self, signal: Signal) -> Result<Option<Signal>> {
println!("Received: {:?}", signal);
Ok(None)
}
}
node.register_handler(MyHandler).await?;
Managing Synapses
let synapses = node.synapses().await?;
for synapse in synapses {
println!("{}: weight={}, state={:?}", synapse.id, synapse.weight, synapse.state);
}
Module References
Node
Node initialization, lifecycle, and management
Signal
Signal creation, types, and encoding
Synapse
Synapse management and configuration
Adapter
Adapter trait and built-in implementations