Skip to main content

reinhardt_views/
lib.rs

1//! # Reinhardt Views
2//!
3//! Generic views for Reinhardt framework, inspired by Django's class-based views.
4//!
5//! ## Features
6//!
7//! - **ListView**: Display a list of objects with pagination support
8//! - **DetailView**: Display a single object
9//! - **CreateView**: Handle object creation
10//! - **UpdateView**: Handle object updates
11//! - **DeleteView**: Handle object deletion
12//! - **Browsable API**: HTML rendering for interactive API exploration
13//! - **Interactive Docs**: Swagger UI-like documentation interface
14//! - **Form Generation**: Automatic form generation for POST/PUT/PATCH methods
15//! - **Syntax Highlighting**: JSON response highlighting with customizable color schemes
16//!
17//! ## Example
18//!
19//! ```rust,ignore
20//! use reinhardt_views::{ListView, DetailView};
21//! # use reinhardt_http::{Request, Response};
22//! # use reinhardt_core::exception::Error;
23//!
24//! # #[derive(Debug, Clone)]
25//! # struct User {
26//! #     id: Option<i64>,
27//! #     username: String,
28//! #     email: String,
29//! # }
30//!
31//! // Create a ListView to display paginated users
32//! let list_view = ListView::<User>::new()
33//!     .with_paginate_by(10)
34//!     .with_ordering(vec!["-id".to_string()]);
35//!
36//! // Create a DetailView to display a single user
37//! let detail_view = DetailView::<User>::new()
38//!     .with_context_object_name("user");
39//!
40//! // Use the views in request handlers
41//! # async fn handle_list(request: Request) -> Result<Response, Error> {
42//! #     list_view.dispatch(request).await
43//! # }
44//! #
45//! # async fn handle_detail(request: Request) -> Result<Response, Error> {
46//! #     detail_view.dispatch(request).await
47//! # }
48//! ```
49
50pub mod viewsets;
51
52// Module declarations from merged views-core
53pub mod admin;
54pub mod browsable_api;
55pub mod generic;
56pub mod openapi;
57pub mod openapi_inspector;
58
59// Module declarations
60mod core;
61mod detail;
62mod list;
63mod mixins;
64
65// Re-export public API
66pub use core::{Context, View};
67pub use detail::DetailView;
68pub use list::ListView;
69pub use mixins::{MultipleObjectMixin, SingleObjectMixin};
70
71// Re-export viewsets commonly used types at crate root
72pub use viewsets::{Action, ViewSet};
73
74// Re-export Generic API Views
75pub use generic::{
76	CreateAPIView, DestroyAPIView, ListAPIView, ListCreateAPIView, RetrieveAPIView,
77	RetrieveDestroyAPIView, RetrieveUpdateAPIView, RetrieveUpdateDestroyAPIView, UpdateAPIView,
78};