chopin_core/lib.rs
1//! # Chopin
2//!
3//! A thread-per-core HTTP framework for Rust with zero async overhead.
4//!
5//! Chopin uses a shared-nothing architecture: each worker thread owns its own
6//! epoll/kqueue event loop, socket accept, router clone, and connection pool.
7//! There are no `Arc`, no `Mutex`, and no async runtimes.
8//!
9//! ## Quick Start
10//!
11//! ```rust,no_run
12//! use chopin_core::{get, Context, Response, Chopin};
13//!
14//! #[get("/")]
15//! fn index(_ctx: Context) -> Response {
16//! Response::text("Hello, world!")
17//! }
18//!
19//! fn main() {
20//! Chopin::new()
21//! .mount_all_routes()
22//! .serve("0.0.0.0:8080")
23//! .unwrap();
24//! }
25//! ```
26
27// Use mimalloc as the global allocator for all binaries that link chopin-core.
28// mimalloc significantly outperforms the system allocator under high concurrency
29// due to its per-thread free-lists, low fragmentation, and cache-aware design.
30use mimalloc::MiMalloc;
31
32#[global_allocator]
33static GLOBAL: MiMalloc = MiMalloc;
34
35pub mod conn;
36pub mod error;
37pub mod extract;
38pub mod headers;
39pub mod http;
40pub mod http2;
41pub mod http_date;
42pub mod json;
43pub mod metrics;
44pub mod multipart;
45pub mod openapi;
46pub mod parser;
47pub mod router;
48pub mod server;
49pub mod slab;
50pub mod syscalls;
51pub mod timer;
52pub mod websocket;
53pub mod worker;
54
55// Re-exports for users
56pub use error::{ChopinError, ChopinResult};
57pub use extract::{FromRequest, Json, Query};
58pub use headers::{Header, HeaderValue, Headers, IntoHeaderValue};
59pub use http::{Body, Context, Method, OwnedFd, Request, Response};
60pub use json::KJson;
61pub use router::{RouteDef, Router};
62pub use server::{Chopin, Server};
63
64// Re-export for macros
65pub use chopin_macros::*;
66pub use inventory;