Tnuctipun
The Tnuctipun of Ringworld — ancient, subversive, ingenious — or a type-safe MongoDB builder library.
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
Usage
Add this to your Cargo.toml:
[]
= "0.1.2"
The library only requires the bson crate for MongoDB document types and provides type-safe query building capabilities.
Example
use ;
use ;
// Type-safe filter building with compile-time field validation
let mut filter_builder = ;
filter_builder.;
filter_builder.;
// Convert to MongoDB document
let filter_doc = filter_builder.and;
// Results in: { "$and": [{ "name": "John" }, { "age": { "$gt": 18 } }] }
// Type-safe projection building with method chaining
let projection_doc =
.
.
. // Hide sensitive data
.build;
// Results in: { "name": 1, "age": 1, "email": 0 }
// Type-safe update building with compile-time field validation
let update_doc =
.
.
.
.build;
// Results in: {
// "$set": { "name": "Jane" },
// "$inc": { "age": 1 },
// "$unset": { "email": "" }
// }
Documentation
- User Guide - Comprehensive documentation with examples and tutorials
- API Documentation - Complete API reference
- Crates.io Documentation - Released version docs
Development
For information about contributing and releasing new versions, see:
- Release Guide - How to publish new versions
- Changelog - What's new in each version
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.