Crate tnuctipun

Crate tnuctipun 

Source
Expand description

§Tnuctipun

Tnuctipun Logo

Type-safe MongoDB query and update builder for Rust

The Tnuctipun of Ringworld — ancient, subversive, ingenious — or a type-safe MongoDB builder library.

§Overview

Tnuctipun provides compile-time type safety for MongoDB operations by generating field witnesses and enabling type-checked query, projection, and update building.

§Features

  • Type-safe field access: Use compile-time validated field names
  • MongoDB query building: Build complex queries with type safety
  • MongoDB projection building: Create projections with fluent method chaining
  • MongoDB update building: Create update documents with type-safe field operations
  • Derive macros: Automatically generate field witnesses and comparable traits
  • Compile-time validation: Catch field name typos and type mismatches at compile time

§Quick Start

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

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

// Type-safe filter building with compile-time field validation
let filter_doc = empty::<User>()
  .eq::<user_fields::Name, _>("John".to_string())
  .gt::<user_fields::Age, _>(18)
  .and(); // Convert to MongoDB document

For comprehensive documentation, see the User Guide.

§Builder modules

Re-exports§

pub use crate::field_filters::FieldFilterBuilder;
pub use crate::field_witnesses::FieldName;
pub use crate::field_witnesses::HasField;
pub use crate::field_witnesses::NonEmptyStruct;
pub use crate::mongo_comparable::MongoComparable;
pub use crate::path::Path;

Modules§

field_filters
field_witnesses
filters
mongo_comparable
path
projection
updates

Derive Macros§

FieldWitnesses
Procedural macro to generate field witnesses for a struct.
MongoComparable
Procedural macro to generate MongoComparable implementations for a struct.