| Crates.io | zero-trust-sdk |
| lib.rs | zero-trust-sdk |
| version | 0.1.0 |
| created_at | 2025-09-27 09:13:19.042673+00 |
| updated_at | 2025-09-27 09:13:19.042673+00 |
| description | Rust SDK for Zero Trust Blockchain Database - Secure, programmable access to zero-trust data storage |
| homepage | https://zerotrust.com |
| repository | https://github.com/your-org/zero-trust-sdk |
| max_upload_size | |
| id | 1857116 |
| size | 221,858 |
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.
Add this to your Cargo.toml:
[dependencies]
zero-trust-sdk = "0.1.0"
use zero_trust_sdk::{ZeroTrustClient, Config};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = Config::new("http://localhost:3000", "your-api-key");
let client = ZeroTrustClient::new(config).await?;
// Authenticate
client.auth().login("username", "password").await?;
// Query data
let result = client.database().query("SELECT * FROM users").await?;
println!("Query result: {:?}", result);
Ok(())
}
client.auth().login("username", "password").await?;
client.auth().wallet_auth("0x...", "signature").await?;
let users = client.database().query("SELECT * FROM users WHERE active = true").await?;
client.database().create_table("users", vec![
("id", "SERIAL PRIMARY KEY"),
("name", "VARCHAR(100)"),
("email", "VARCHAR(255) UNIQUE"),
("created_at", "TIMESTAMP DEFAULT CURRENT_TIMESTAMP"),
]).await?;
client.database().execute(
"INSERT INTO users (name, email) VALUES ($1, $2)",
vec!["John Doe", "john@example.com"]
).await?;
ZERO_TRUST_API_URL=http://localhost:3000
ZERO_TRUST_API_KEY=your-api-key
Create a zero_trust.toml file:
api_url = "http://localhost:3000"
api_key = "your-api-key"
timeout = 30
retry_attempts = 3
let config = Config::builder()
.api_url("http://localhost:3000")
.api_key("your-api-key")
.timeout(Duration::from_secs(30))
.retry_attempts(3)
.build();
See the examples/ directory for complete usage examples:
examples/test_sdk.rs - Basic SDK usage and operationscargo run --example test_sdk
cargo test
# Enable all features
cargo build --features full
# Enable specific features
cargo build --features "migration sync logging"
default: Enables migration and sync featuresmigration: Database migration support with progress indicatorssync: Synchronous database operationslogging: Structured logging with tracingfull: All features enabledThe SDK provides comprehensive error types:
use zero_trust_sdk::error::{ZeroTrustError, AuthError, DatabaseError};
match client.auth().login("user", "pass").await {
Ok(_) => println!("Login successful"),
Err(ZeroTrustError::Auth(AuthError::InvalidCredentials)) => {
println!("Invalid username or password");
},
Err(ZeroTrustError::Network(e)) => {
println!("Network error: {}", e);
},
Err(e) => println!("Other error: {}", e),
}
MIT License - see LICENSE file for details.
Please refer to the main Zero Trust project repository for contribution guidelines.