💡 Code Examples
Production-ready code examples for building with Avx
🔥 15+ Categories
📝 50+ Examples
✅ Production Ready
🔐 Encryption
AES-256 Encryption
Encrypt and decrypt with AES-256-GCM
use avx_crypto::{Aes256Gcm, Nonce, Key};
let key = Key::random();
let cipher = Aes256Gcm::new(&key)?;
let plaintext = b"Secret message";
let nonce = Nonce::random();
let ciphertext = cipher.encrypt(&nonce, plaintext)?;
let decrypted = cipher.decrypt(&nonce, &ciphertext)?;
🌐 HTTP Server
REST API
Build high-performance REST API
use avx_http::{Server, Router, Json};
let app = Router::new()
.get("/", index)
.get("/users/:id", get_user)
.post("/users", create_user);
Server::bind("0.0.0.0:8080")
.serve(app)
.await?;
💾 Database
SQL Queries
Type-safe database operations
use avx_db::{Database, query};
let db = Database::connect("postgres://localhost").await?;
let users = query("SELECT * FROM users WHERE age > $1")
.bind(18)
.fetch_all::(&db)
.await?;
🎮 GPU Computing
CUDA Kernel
Run parallel computations on GPU
use avx_gpu::{Device, Kernel, Buffer};
let device = Device::cuda(0)?;
let input = Buffer::from_slice(&device, &data)?;
let output = Buffer::zeros(&device, data.len())?;
let kernel = Kernel::from_source(&device, code)?;
kernel.launch(grid, block, &[&input, &output])?;
🔄 Distributed Systems
Raft Consensus
Build fault-tolerant distributed systems
use avx_raft::{RaftNode, Config};
let node = RaftNode::new(node_id, peers, config)?;
if node.is_leader() {
node.propose(entry).await?;
}