neocrates/
lib.rs

1#![doc(html_root_url = "https://docs.rs/neocrates/0.1.2")]
2#![allow(missing_docs)]
3#![allow(rustdoc::missing_crate_level_docs)]
4
5//! # Neocrates
6//!
7//! A comprehensive Rust toolkit targeting Web, AWS, Database, Redis, and Cryptography scenarios.
8//!
9//! Modules and their dependencies are gated by features for tree-shaking. The middleware uses a pluggable TokenStore and only requires the "web" feature. When the "redis" feature is enabled, you can provide a Redis-backed store; otherwise an in-memory store is used by default.
10//!
11//! ## Feature Groups
12//!
13//! - web: Web capabilities (Axum/Tower/Hyper, HTTP, URL handling, common middleware and response utilities)
14//! - aws: AWS capabilities (aws-config, aws-types, S3, STS). Note: `aws` includes shared S3/STS dependencies
15//!   - awss3: S3-only (requires aws-sdk-s3 + shared aws-config/types)
16//!   - awssts: STS-only (requires aws-sdk-sts + shared aws-config/types)
17//! - database: Database and Diesel capabilities (diesel, deadpool/connection pooling, migrations)
18//! - redis: Redis and caching (redis, bb8, bb8-redis, moka)
19//! - crypto: Cryptography and hashing (argon2, hmac, ring, sha2)
20//! - sms: SMS-related modules (if they depend on HTTP, enable together with "web")
21//! - full: Enable all features
22//!
23//! Note: Modules are compiled only when their feature is enabled; related dependencies are marked optional in Cargo.toml and aggregated via
24//! the `[features]` section. See the example below.
25//!
26//! ## Cargo.toml Example
27//!
28//! ```toml
29//! [features]
30//! default = []
31//! # Aggregated features
32//! web = ["dep:axum", "dep:tower", "dep:tower-http", "dep:hyper", "dep:reqwest", "dep:url", "dep:urlencoding"]
33//! aws = ["awss3", "awssts", "dep:aws-config", "dep:aws-types"]
34//! awss3 = ["dep:aws-sdk-s3", "dep:aws-config", "dep:aws-types"]
35//! awssts = ["dep:aws-sdk-sts", "dep:aws-config", "dep:aws-types"]
36//! diesel = ["dep:diesel", "dep:deadpool", "dep:deadpool-diesel", "dep:diesel_migrations"]
37//! redis = ["dep:redis", "dep:bb8", "dep:bb8-redis", "dep:moka"]
38//! crypto = ["dep:argon2", "dep:hmac", "dep:ring", "dep:sha2"]
39//! sms = [] # If HTTP is needed, enable together with "web"
40//! full = ["web", "aws", "awss3", "awssts", "diesel", "redis", "crypto", "sms"]
41//!
42//! [dependencies]
43//! # Mark related dependencies as optional
44//! axum = { version = "0.8", features = ["macros"], optional = true }
45//! tower = { version = "0.5", optional = true }
46//! tower-http = { version = "0.6", optional = true }
47//! hyper = { version = "1.6", features = ["full"], optional = true }
48//! reqwest = { version = "0.12", features = ["gzip", "json"], optional = true }
49//! url = { version = "2.5.4", optional = true }
50//! urlencoding = { version = "2.1.3", optional = true }
51//!
52//! aws-config = { version = "1.1.7", features = ["behavior-version-latest"], optional = true }
53//! aws-sdk-s3 = { version = "1.83.0", optional = true }
54//! aws-sdk-sts = { version = "1.66.0", optional = true }
55//! aws-types = { version = "1.3.7", optional = true }
56//!
57//! diesel = { version = "2", features = ["chrono", "serde_json"], optional = true }
58//! deadpool = { version = "0.12", optional = true }
59//! deadpool-diesel = { version = "0.6", features = ["postgres"], optional = true }
60//! diesel_migrations = { version = "2", optional = true }
61//!
62//! redis = { version = "0.32", optional = true }
63//! bb8 = { version = "0.9", optional = true }
64//! bb8-redis = { version = "0.24", optional = true }
65//! moka = { version = "0.12", features = ["future"], optional = true }
66//!
67//! argon2 = { version = "0.5", optional = true }
68//! hmac = { version = "0.12", optional = true }
69//! sha2 = { version = "0.10", optional = true }
70//! ring = { version = "0.17.14", optional = true }
71//! ```
72//!
73//! The above is only an example; align versions with your actual dependencies.
74
75// =========================
76// Core re-exports (always)
77// =========================
78
79pub use anyhow;
80pub use async_trait;
81pub use bon;
82pub use chrono;
83pub use dashmap;
84pub use indexmap;
85pub use lazy_static;
86pub use log;
87pub use once_cell;
88pub use rand;
89pub use regex;
90pub use schemars;
91pub use serde;
92pub use serde_json;
93pub use thiserror;
94pub use tokio;
95pub use tracing;
96pub use uuid;
97pub use validator;
98
99// =========================
100// Web re-exports (feature)
101// =========================
102
103#[cfg(any(feature = "web", feature = "full"))]
104pub use axum;
105#[cfg(any(feature = "web", feature = "full"))]
106pub use hyper;
107#[cfg(any(feature = "web", feature = "full"))]
108pub use reqwest;
109#[cfg(any(feature = "web", feature = "full"))]
110pub use tower;
111#[cfg(any(feature = "web", feature = "full"))]
112pub use tower_http;
113#[cfg(any(feature = "web", feature = "full"))]
114pub use url;
115#[cfg(any(feature = "web", feature = "full"))]
116pub use urlencoding;
117
118// =========================
119// AWS re-exports (feature)
120// =========================
121
122// Shared AWS config/types are available under any AWS sub-feature or aws/full
123#[cfg(any(
124    feature = "aws",
125    feature = "awss3",
126    feature = "awssts",
127    feature = "full"
128))]
129pub use aws_config;
130#[cfg(any(
131    feature = "aws",
132    feature = "awss3",
133    feature = "awssts",
134    feature = "full"
135))]
136pub use aws_types;
137
138// S3 is available only under awss3 or aws/full
139#[cfg(any(feature = "aws", feature = "awss3", feature = "full"))]
140pub use aws_sdk_s3;
141
142// STS is available only under awssts or aws/full
143#[cfg(any(feature = "aws", feature = "awssts", feature = "full"))]
144pub use aws_sdk_sts;
145
146// =============================
147// Database diesel re-exports (feature)
148// =============================
149
150#[cfg(any(feature = "diesel", feature = "full"))]
151pub use deadpool;
152#[cfg(any(feature = "diesel", feature = "full"))]
153pub use deadpool_diesel;
154#[cfg(any(feature = "diesel", feature = "full"))]
155pub use diesel;
156#[cfg(any(feature = "diesel", feature = "full"))]
157pub use diesel_migrations;
158
159// =========================
160// Redis re-exports (feature)
161// =========================
162
163#[cfg(any(feature = "redis", feature = "full"))]
164pub use bb8;
165#[cfg(any(feature = "redis", feature = "full"))]
166pub use bb8_redis;
167#[cfg(any(feature = "redis", feature = "full"))]
168pub use moka;
169#[cfg(any(feature = "redis", feature = "full"))]
170pub use redis;
171
172// ==========================
173// Crypto re-exports (feature)
174// ==========================
175
176#[cfg(any(feature = "crypto", feature = "full"))]
177pub use argon2;
178#[cfg(any(feature = "crypto", feature = "full"))]
179pub use hmac;
180#[cfg(any(feature = "crypto", feature = "full"))]
181pub use ring;
182#[cfg(any(feature = "crypto", feature = "full"))]
183pub use sha2;
184
185// ==================
186// Module declarations
187// ==================
188
189// Core and common modules (always available)
190pub mod helper;
191#[cfg(any(feature = "logger", feature = "full"))]
192pub mod logger;
193
194// Web modules
195#[cfg(any(feature = "web", feature = "full"))]
196pub mod middlewares;
197#[cfg(any(feature = "web", feature = "full"))]
198pub mod response;
199
200// AWS
201#[cfg(any(feature = "aws", feature = "awssts", feature = "full"))]
202pub mod aws;
203#[cfg(any(feature = "aws", feature = "awss3", feature = "full"))]
204pub mod awss3;
205#[cfg(any(feature = "aws", feature = "awssts", feature = "full"))]
206pub mod awssts;
207
208// Database
209#[cfg(any(feature = "diesel", feature = "full"))]
210pub mod dieselhelper;
211
212// Redis
213#[cfg(any(feature = "redis", feature = "full"))]
214pub mod rediscache;
215
216// Crypto
217#[cfg(any(feature = "crypto", feature = "full"))]
218pub mod crypto;
219
220// SMS (if it depends on HTTP/network requests, enable together with "web")
221#[cfg(any(feature = "sms", feature = "full"))]
222pub mod sms;