Documentation | API Reference | Quick Start | Contributing
A production-grade, high-performance schema and data transformations library for Rust, designed with a clean, intuitive, and developer-friendly API.
[!NOTE] This Project aims to be production ready, while it is relatively new project you can find some interesting features which may simplify your Rust project structured validations and data transformations.
⭐️ If you love adapters, make sure to give it a star! ⭐️
- Prerequisites
- Supported Platforms
- Installation
- Quick Start
- Usage Examples
- Declarative Macro Reference Table
- Performance & Benchmarks
- Building & Testing
- Documentation
- Contributing
- License
- Links
| Feature | Description | Documentation |
|---|---|---|
| Declarative Derive Macro | User-friendly data modeling interface via #[derive(Schema)] |
Docs |
| Comprehensive Field Rules | email, url, min/max bounds, regex, non_empty, alphanumeric, positive, negative, and non_zero | Docs |
| Coercion & Strict Mode | Optional strict type enforcement to prevent implicit casting / type parsing | Docs |
| Dynamic Schema Builders | Build complex nested structural validations dynamically at runtime | Docs |
| Robust Parsing Engine | Native structured JSON parsing with precise escape seq bounds | Docs |
| Functional Pipelines | Chain value adjustments, defaults, transformations, and filters cleanly | Docs |
| Nested Validation Error Paths | Accumulates nested object failures using accurate dot-notation paths | Docs |
Prerequisites
Before installing Adapters, ensure you have the following:
| Requirement | Version | Notes |
|---|---|---|
| Rust | Stable 1.85+ | 2024 Edition supported natively |
| Operating System | Windows, Linux, macOS | Cross-platform |
Supported Platforms
Adapters supports a wide range of platforms and architectures:
| Platform | Architectures | Status |
|---|---|---|
| Windows | x86_64, aarch64, x86 | Full support |
| Linux | x86_64, aarch64, riscv64 | Full support |
| macOS | x86_64, aarch64 (Apple Silicon) | Full support |
Installation
Method 1: Cargo Add (Recommended)
Add Adapters to your cargo project dynamically:
Method 2: Manual Cargo.toml Configuration
Add this directly to your Cargo.toml dependencies block:
[]
= "0.0.0"
Quick Start
use *;
Usage Examples
Basic Declarative Validation
use *;
Advanced Macro Validations
use *;
Programmatic Builder Validation
use *;
use ;
use SchemaValidator;
let schema = new
.field
.field;
Nested Model Validation
use *;
Field Transformation Pipelines & Sanitization
Chaining data mapping and sanitization rules is highly expressive using functional pipelines. This is exceptionally useful when consuming legacy third-party Webhook payloads:
use *;
use ;
// Create a field mapper to rename legacy API keys
let legacy_mapper = new
.rename
.rename;
// Build a transformation pipeline
let pipeline = new
.push
.push;
// Process a raw legacy payload
let legacy_payload = Object;
let clean_value = pipeline.run.unwrap;
println!;
// Output will have "title" in uppercase, and "usr_id" renamed to "user_id"!
Alias Key Remapping
If you don't need runtime pipelines and only require direct structural key mapping from your JSON API payloads, use the #[schema(alias = "...")] helper:
use *;
Declarative Macro Reference Table
Configure your struct fields using the #[schema(...)] helper:
| Attribute Rule | Supported Types | Action Description |
|---|---|---|
min_length = <usize> |
String |
Enforces a minimum string character count. |
max_length = <usize> |
String |
Enforces a maximum string character count. |
non_empty |
String |
Restricts string to be non-empty (minimum 1 character). |
alphanumeric |
String |
Enforces only alphanumeric characters. |
email |
String |
Matches the string value against standard RFC 5322 format. |
url |
String |
Matches the string value against standard URL layout. |
regex = "<pattern>" |
String |
Validates string matching using custom Rust regex. |
min = <number> |
All numbers | Restricts numbers to be greater than or equal to value. |
max = <number> |
All numbers | Restricts numbers to be less than or equal to value. |
positive |
All numbers | Checks if numbers are strictly positive ($>0$). |
negative |
All numbers | Checks if numbers are strictly negative ($<0$). |
non_zero |
All numbers | Restricts numbers to exclude exact $0$ value. |
optional |
All types | Declares the field is non-required and defaults to null. |
strict |
All types | Opts into strict validation: no implicit type coercions. |
default = <expr> |
All types | Populates field with expression value when key is absent. |
Performance & Benchmarks
Adapters is engineered for extreme data validation and parsing throughput. It implements high-performance zero-allocation parsing routines, compact error trees, and static struct validation maps.
To run benchmarks locally:
Building & Testing
# Check compiler requirements and clippy lints
# Run all unit, integration, and doctests
Documentation
Online Documentation
Full structured guide and dynamic api walkthroughs are available natively at: https://muhammad-fiaz.github.io/adapters
Generating Local Documentation
To generate and view crate-level API documentation locally:
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. See CONTRIBUTING.md for contribution guidelines.
License
MIT License - see LICENSE for details.
Links
- Documentation: https://muhammad-fiaz.github.io/adapters
- Repository: https://github.com/muhammad-fiaz/adapters
- Issues: https://github.com/muhammad-fiaz/adapters/issues