Rust Core
zypp-labs-core is the foundational Rust implementation of the Zypp SDK — intent engine, local state, sync, settlement, crypto, and transport. All platform SDKs are bindings over this core.
When to Use Rust Core
- Server-side intent processing
- CLI tools and automation
- Native desktop applications
- Game engines that use Rust (Bevy, etc.)
- Custom binding layers for new platforms
Adding to Your Project
[dependencies]
zypp-labs-core = { path = "../rust-core" }
zypp-labs-core supports serde + bincode for serialization, ed25519-dalek for signatures, uuid for intent identity, and aes-gcm for encrypted storage.
Module Overview
| Module | File | Purpose |
|---|---|---|
| Types | types.rs | Core type definitions: Intent, QueueEntry, QueueStatus, IntentPayload, TrustTier, security envelopes |
| Intent | intent.rs | IntentEngine — create, sign, submit, poll, cancel intents |
| Local State | local_state.rs | LocalStateDb — RocksDB-backed persistent queue, KindRegistry, content-hash dedup, trust tier validation |
| Sync | sync.rs | SyncClient — connectivity-aware coordination, nonce registry, signature verification |
| Settlement | settlement.rs | SettlementClient — route to exit target, primary/degraded strategy, record outcome |
| Transfer | transfer.rs | TransferEngine — packet creation, decoding, BLE/NFC/QR adapters |
| Crypto | crypto.rs | Ed25519 signing and verification |
| Tamper | tamper.rs | HMAC-SHA256 tamper-evident envelope |
| Templates | templates/ | Starter templates: ArcadeTemplate, TicketTemplate |
Core API
IntentEngine
use zypp_labs_core::ZyppEngine;
use zypp_labs_core::intent::TrustTier;
let engine = ZyppEngine::new();
// Create an intent
let intent = engine.create_intent("move_player", r#"{"x":10,"y":20}"#, TrustTier::Unsigned);
// Sign and submit
engine.sign_and_submit(&intent);
// Poll status
let status = engine.poll_status(&intent.id);
LocalStateDb
use zypp_labs_core::local_state::LocalStateDb;
// Initialize with RocksDB path
let mut db = LocalStateDb::new("/path/to/db")?;
// Save an entry
db.save(&entry)?;
// Load an entry
let loaded = db.load(&intent_id)?;
// List all entries
let all = db.list()?;
SyncClient
use zypp_labs_core::sync::SyncClient;
let mut sync = SyncClient::new();
sync.connect("relay.zypp.fun:8443")?;
// Sync pushes pending intents to the relay
// Events are received via callback
SettlementClient
use zypp_labs_core::settlement::{SettlementClient, ExitTarget, ExitStrategy};
let mut settlement = SettlementClient::new();
let result = settlement.finalize(
&entry,
ExitTarget::SolanaRpc { rpc_url: "https://api.mainnet-beta.solana.com".into() },
)?;
Full Example
use zypp_labs_core::ZyppEngine;
use zypp_labs_core::types::{Intent, IntentType, IntentPayload, FreeFormPayload, TrustTier};
use zypp_labs_core::local_state::LocalStateDb;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize engine
let engine = ZyppEngine::new();
let mut db = LocalStateDb::new("./zypp_queue")?;
// Create intent
let intent = engine.create_intent(
"swap_tokens",
r#"{"from":"SOL","to":"USDC","amount":100_000_000}"#,
TrustTier::Signed,
);
// Queue locally
let entry = engine.enqueue(&intent)?;
// Sync when online
if let Ok(mut sync) = engine.sync_connect("relay.zypp.fun:8443") {
sync.push(&entry)?;
}
// Settle on Solana
let result = engine.settle(
&entry,
"https://api.devnet.solana.com",
ExitType::SolanaRpc,
)?;
println!("Settled: {:?}", result);
Ok(())
}
Building from Source
# Build the core library
cargo build --manifest-path rust-core/Cargo.toml
# Run tests (220+ across the stack)
cargo test --manifest-path rust-core/Cargo.toml --all
# Run integration tests
cargo test --manifest-path rust-core/Cargo.toml --test integration
The Rust core compiles to static libraries for each platform. Expo and Unity SDKs consume the compiled artifacts from their respective native plugin directories.
Next Steps
- Explore the Intent type system in detail
- Configure Settlement for your exit targets
- See Examples for full Rust applications