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 base64;
82pub use bon;
83pub use chrono;
84pub use dashmap;
85pub use hex;
86pub use indexmap;
87pub use lazy_static;
88pub use log;
89pub use md5;
90pub use once_cell;
91pub use rand;
92pub use regex;
93pub use schemars;
94pub use serde;
95pub use serde_json;
96pub use thiserror;
97pub use tokio;
98pub use tracing;
99pub use uuid;
100pub use validator;
101
102// Image processing (always available as dependencies are not optional)
103pub use image;
104pub use imageproc;
105
106// =========================
107// Web re-exports (feature)
108// =========================
109
110#[cfg(any(feature = "web", feature = "full"))]
111pub use axum;
112#[cfg(any(feature = "web", feature = "full"))]
113pub use hyper;
114#[cfg(any(feature = "web", feature = "full"))]
115pub use reqwest;
116#[cfg(any(feature = "web", feature = "full"))]
117pub use tower;
118#[cfg(any(feature = "web", feature = "full"))]
119pub use tower_http;
120#[cfg(any(feature = "web", feature = "full"))]
121pub use url;
122#[cfg(any(feature = "web", feature = "full"))]
123pub use urlencoding;
124
125// =========================
126// AWS re-exports (feature)
127// =========================
128
129// Shared AWS config/types are available under any AWS sub-feature or aws/full
130#[cfg(any(
131 feature = "aws",
132 feature = "awss3",
133 feature = "awssts",
134 feature = "full"
135))]
136pub use aws_config;
137#[cfg(any(
138 feature = "aws",
139 feature = "awss3",
140 feature = "awssts",
141 feature = "full"
142))]
143pub use aws_types;
144
145// S3 is available only under awss3 or aws/full
146#[cfg(any(feature = "aws", feature = "awss3", feature = "full"))]
147pub use aws_sdk_s3;
148
149// STS is available only under awssts or aws/full
150#[cfg(any(feature = "aws", feature = "awssts", feature = "full"))]
151pub use aws_sdk_sts;
152
153// =============================
154// Database diesel re-exports (feature)
155// =============================
156
157#[cfg(any(feature = "diesel", feature = "full"))]
158pub use deadpool;
159#[cfg(any(feature = "diesel", feature = "full"))]
160pub use deadpool_diesel;
161#[cfg(any(feature = "diesel", feature = "full"))]
162pub use diesel;
163#[cfg(any(feature = "diesel", feature = "full"))]
164pub use diesel_migrations;
165
166// =========================
167// Redis re-exports (feature)
168// =========================
169
170#[cfg(any(feature = "redis", feature = "full"))]
171pub use bb8;
172#[cfg(any(feature = "redis", feature = "full"))]
173pub use bb8_redis;
174#[cfg(any(feature = "redis", feature = "full"))]
175pub use moka;
176#[cfg(any(feature = "redis", feature = "full"))]
177pub use redis;
178
179// ==========================
180// Crypto re-exports (feature)
181// ==========================
182
183#[cfg(any(feature = "crypto", feature = "full"))]
184pub use argon2;
185#[cfg(any(feature = "crypto", feature = "full"))]
186pub use hmac;
187#[cfg(any(feature = "crypto", feature = "full"))]
188pub use ring;
189#[cfg(any(feature = "crypto", feature = "full"))]
190pub use sha2;
191
192// ==================
193// Module declarations
194// ==================
195
196// Core and common modules (always available)
197pub mod helper;
198#[cfg(any(feature = "logger", feature = "full"))]
199pub mod logger;
200
201// Web modules
202#[cfg(any(feature = "web", feature = "full"))]
203pub mod middlewares;
204#[cfg(any(feature = "web", feature = "full"))]
205pub mod response;
206
207// AWS
208#[cfg(any(feature = "aws", feature = "awssts", feature = "full"))]
209pub mod aws;
210#[cfg(any(feature = "aws", feature = "awss3", feature = "full"))]
211pub mod awss3;
212#[cfg(any(feature = "aws", feature = "awssts", feature = "full"))]
213pub mod awssts;
214
215// Database
216#[cfg(any(feature = "diesel", feature = "full"))]
217pub mod dieselhelper;
218
219// Redis
220#[cfg(any(feature = "redis", feature = "full"))]
221pub mod rediscache;
222
223// Crypto
224#[cfg(any(feature = "crypto", feature = "full"))]
225pub mod crypto;
226
227// SMS (if it depends on HTTP/network requests, enable together with "web")
228#[cfg(any(feature = "sms", feature = "full"))]
229pub mod sms;
230
231// Captcha (requires web and redis features for full functionality)
232#[cfg(any(feature = "web", feature = "full"))]
233pub mod captcha;
234
235#[cfg(all(feature = "web", feature = "redis", feature = "full"))]
236pub mod auth;