Zero Trust Rust SDK
Rust SDK for Zero Trust Blockchain Database - Secure, programmable access to zero-trust data storage.
A Rust client library for the Zero Trust Blockchain Database System, where user authentication/management is handled by traditional PostgreSQL, while application data lives entirely on-chain. Provides immutable, auditable, and verifiable data storage with familiar SQL interfaces.
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Quick Start
use ;
async
Features
- Async/await support - Built on Tokio for non-blocking operations
- Type-safe API - Leverages Rust's type system for safer database operations
- Flexible authentication - Support for traditional login and Web3 wallet authentication
- SQL interface - Familiar SQL syntax for blockchain data operations
- Migration support - Database schema migration capabilities
- Configuration management - File-based and programmatic configuration
- Error handling - Comprehensive error types with detailed context
Authentication
Traditional Login
client.auth.login.await?;
Web3 Wallet Authentication
client.auth.wallet_auth.await?;
Database Operations
Querying Data
let users = client.database.query.await?;
Creating Tables
client.database.create_table.await?;
Inserting Data
client.database.execute.await?;
Configuration
Environment Variables
ZERO_TRUST_API_URL=http://localhost:3000
ZERO_TRUST_API_KEY=your-api-key
Configuration File
Create a zero_trust.toml file:
= "http://localhost:3000"
= "your-api-key"
= 30
= 3
Programmatic Configuration
let config = builder
.api_url
.api_key
.timeout
.retry_attempts
.build;
Examples
See the examples/ directory for complete usage examples:
examples/test_sdk.rs- Basic SDK usage and operations
Development
Running Examples
Running Tests
With Features
# Enable all features
# Enable specific features
Features
default: Enablesmigrationandsyncfeaturesmigration: Database migration support with progress indicatorssync: Synchronous database operationslogging: Structured logging with tracingfull: All features enabled
Error Handling
The SDK provides comprehensive error types:
use ;
match client.auth.login.await
License
MIT License - see LICENSE file for details.
Contributing
Please refer to the main Zero Trust project repository for contribution guidelines.