anycms_core/
lib.rs

1//! anycms-core
2//!
3//! A unified API response library supporting multiple Rust web frameworks.
4//!
5//! ## Features
6//! - `actix` (default): Support for actix-web framework
7//! - `axum`: Support for axum framework
8//! - `full`: Enable all framework integrations
9//!
10//! ## Basic Usage
11//! ```rust
12//! use anycms_core::ApiResult;
13//! use serde::Serialize;
14//!
15//! #[derive(Serialize)]
16//! struct User {
17//!     id: u32,
18//!     name: String,
19//! }
20//!
21//! fn handle_request() -> ApiResult<User> {
22//!     let user = User { id: 1, name: "Alice".to_string() };
23//!     ApiResult::value(user)
24//! }
25//! ```
26//!
27//! ## Error Handling
28//! ```rust
29//! use anycms_core::{ApiResult, ApiError};
30//!
31//! fn handle_error() -> ApiResult<String> {
32//!     ApiError::not_found("Resource not found").into()
33//! }
34//! ```
35
36mod pagination;
37mod result;
38
39// Framework-specific implementations
40mod frameworks;
41
42// Core exports (always available)
43pub use pagination::ResultPagination;
44pub use result::{
45    ApiResult, DefaultResult, AnyhowResult, EmptyResult,
46    ErrorCode, ApiError, AppError, IntoApiResult,
47    ResponseData,
48};
49
50// Framework-specific exports (available only when corresponding feature is enabled)
51#[cfg(feature = "actix")]
52pub use frameworks::actix;
53
54#[cfg(feature = "axum")]
55pub use frameworks::axum;