The official Rust SDK for the LLM Native Minimal Protocol (LNMP).
This SDK provides a unified entry point to the entire LNMP ecosystem, leveraging the lnmp meta crate to give you access to all protocol features, from basic encoding to advanced spatial streaming and neural embeddings.
Add the following to your Cargo.toml:
[dependencies]
lnmp = "0.5.12"Note
Most users should depend directly on the lnmp crate from crates.io. This SDK repository serves as a documentation hub and example collection.
use lnmp::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a simple text token
let token = Token::text("Hello LNMP");
// Encode it
let encoded = token.to_lnmp()?;
println!("Encoded: {:?}", encoded);
Ok(())
}The SDK exposes several powerful modules via the lnmp crate:
The foundation of the protocol. Handles basic types, serialization traits, and the unified Token enum.
Key Features:
- Token-based data representation
- LNMP encoding/decoding
- Type-safe serialization
Optimized vector operations for AI applications.
Key Features:
- Multiple quantization types (F32, F16, I8, Binary)
- Delta Mode: Efficiently transmit only changes
- Dimension validation
use lnmp::embedding::Vector;
let vec = Vector::from_f32(vec![0.1, 0.2, 0.3]);Protocol extensions for 3D environments, robotics, and AR/VR.
Key Features:
- Pose tracking (position + orientation)
- SpatialStreamer for efficient updates
- Predictive delta compression
Networking primitives for LNMP.
Key Features:
- Abstract transport layer
- QUIC support
- Message routing
Metadata wrapping for routing, priority, and distributed tracing.
Key Features:
- Priority levels
- Sender/recipient routing
- Custom metadata fields
The SDK includes comprehensive examples demonstrating various LNMP features. Each example is a standalone program you can run directly.
# Navigate to SDK directory
cd sdk/rust
# Run any example with:
cargo run --example <example_name>Learn the fundamentals of LNMP encoding and decoding.
cargo run --example basic_encodingCovers:
- Creating text, number, float, and boolean tokens
- Encoding to LNMP format
- Building compound structures (records)
Work with vector embeddings and delta compression.
cargo run --example embedding_opsCovers:
- Creating F32 vectors
- Computing delta between vectors
- Applying delta patches
- Different quantization types (F16, I8)
3D spatial tracking and streaming for robotics/AR/VR.
cargo run --example spatial_demoCovers:
- Creating spatial poses (position + orientation)
- Tracking multiple objects
- Streaming spatial updates
- LNMP encoding for spatial data
Add metadata, routing, and priority to messages.
cargo run --example envelope_demoCovers:
- Wrapping messages with envelopes
- Setting priority levels
- Adding routing information (sender/recipient)
- Custom metadata fields
Real-world scenario: IoT sensor data pipeline.
cargo run --example complete_workflowCovers:
- Collecting sensor readings
- Generating embeddings for semantic search
- Enriching data with metadata
- Routing through envelopes
- Complete encode-transmit pipeline
Comprehensive demonstration of ALL 11 LNMP modules.
cargo run --example all_modulesCovers:
- Complete module inventory
- Core, Codec, Embedding, Envelope
- LLB, Net, Quant, Sanitize
- SFE, Spatial, Transport
- Real examples from each module
All examples include detailed console output showing:
- Step-by-step operations
- Data transformations
- Encoded LNMP format
- Success confirmations
You can extend LNMP with custom types:
use lnmp::prelude::*;
// Define custom types using Token::record
let custom_message = Token::record(vec![
("type".to_string(), Token::text("custom_sensor")),
("data".to_string(), Token::int(42)),
]);- Use delta mode for frequently updated embeddings
- Enable quantization (F16/I8) for large vectors
- Batch spatial updates when possible
- Set appropriate envelope priorities
- Main Documentation: See project README.md
- API Reference: Run
cargo doc --openin the workspace root - Specification: Check spec/ directory
- More Examples: Browse examples/ in the main repository
Contributions are welcome! Please see the CONTRIBUTING.md file for guidelines.
See LICENSE for details.