ferro_inertia/
lib.rs

1//! # Ferro Inertia
2//!
3//! Server-side [Inertia.js](https://inertiajs.com) adapter for Rust web frameworks.
4//!
5//! This crate provides the core functionality for building Inertia.js responses
6//! in Rust. It is framework-agnostic and can be integrated with any Rust web
7//! framework (Axum, Actix-web, Rocket, etc.).
8//!
9//! ## Features
10//!
11//! - Framework-agnostic design via traits
12//! - Async-safe (no thread-local storage)
13//! - Partial reload support
14//! - Shared props for auth, flash messages, CSRF tokens
15//! - Version conflict detection (409 responses)
16//! - Development mode with Vite HMR support
17//!
18//! ## Quick Start
19//!
20//! ```rust,ignore
21//! use ferro_inertia::{Inertia, InertiaConfig, InertiaRequest};
22//!
23//! // Implement InertiaRequest for your framework's request type
24//! impl InertiaRequest for MyRequest {
25//!     fn inertia_header(&self, name: &str) -> Option<&str> {
26//!         self.headers().get(name).and_then(|v| v.to_str().ok())
27//!     }
28//!     fn path(&self) -> &str {
29//!         self.uri().path()
30//!     }
31//! }
32//!
33//! // In your handler
34//! async fn index(req: MyRequest) -> MyResponse {
35//!     let response = Inertia::render(&req, "Home", serde_json::json!({
36//!         "title": "Welcome"
37//!     }));
38//!
39//!     // Convert InertiaHttpResponse to your framework's response type
40//!     response.into()
41//! }
42//! ```
43//!
44//! ## Framework Integrations
45//!
46//! See the examples directory for integrations with popular frameworks:
47//! - Axum
48//! - Actix-web
49//! - Hyper
50
51mod config;
52mod request;
53mod response;
54mod shared;
55
56pub use config::InertiaConfig;
57pub use request::InertiaRequest;
58pub use response::{Inertia, InertiaHttpResponse, InertiaResponse};
59pub use shared::InertiaShared;
60
61// Re-export serde_json for convenience
62pub use serde_json;