Tnuctipun Logo

Type-safe MongoDB query and update builder for Rust

Welcome to the comprehensive user guide for Tnunctipun, a type-safe MongoDB query and update builder library for Rust.

Quick Navigation

📚 User Guide

🔧 Reference Documentation

📖 Examples

What is Tnuctipun?

Tnuctipun is a compile-time type-safe MongoDB query and update builder for Rust. It provides:

  • Type Safety: Compile-time guarantees that your queries and updates are valid
  • Zero Runtime Cost: No performance overhead compared to manual query building
  • Ergonomic API: Intuitive, chainable interface for building complex queries
  • Field Validation: Ensures referenced fields actually exist in your structs
  • Update Safety: Prevents invalid update operations at compile time

Getting Started

Add Tnunctipun to your Cargo.toml:

[dependencies]
tnuctipun = "0.1.1"

Then start building type-safe MongoDB queries:

use tnuctipun::{FieldWitnesses, MongoComparable, filters::empty, updates};
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize, FieldWitnesses, MongoComparable)]
struct User {
    pub name: String,
    pub email: String,
    pub age: u32,
    pub active: bool,
}

// Type-safe query building
let filter = empty::<User>()
    .eq::<user_fields::Name, _>("Alice".to_string())
    .gte::<user_fields::Age, _>(18)
    .and();

// Type-safe updates
let update = updates::empty::<User>()
    .set::<user_fields::Active, _>(true)
    .inc::<user_fields::Age, _>(1)
    .build();

Community & Support