docs: Add Rustdoc for pages.rs structs and functions
Co-authored-by: aider (openai/andrew/openrouter/sonoma-sky-alpha) <aider@aider.chat>
This commit is contained in:
@@ -12,6 +12,17 @@ use crate::config::ColumnConfig;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
/// Query parameters for the item list endpoint.
|
||||
///
|
||||
/// This struct defines the query parameters used to filter, sort, and paginate
|
||||
/// the list of items displayed on the main page.
|
||||
///
|
||||
/// # Fields
|
||||
///
|
||||
/// * `sort` - Sorting order, defaults to "newest".
|
||||
/// * `tags` - Optional comma-separated list of tags to filter by.
|
||||
/// * `count` - Number of items per page, defaults to 1000.
|
||||
/// * `start` - Starting index for pagination, defaults to 0.
|
||||
pub struct ListQueryParams {
|
||||
#[serde(default = "default_sort")]
|
||||
sort: String,
|
||||
@@ -27,10 +38,39 @@ fn default_sort() -> String {
|
||||
"newest".to_string()
|
||||
}
|
||||
|
||||
/// Provides the default sorting order for item lists.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// A string representing the default sort order: "newest".
|
||||
fn default_count() -> usize {
|
||||
1000
|
||||
}
|
||||
|
||||
/// Provides the default number of items to display per page.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// The default count: 1000.
|
||||
|
||||
/// Adds the web page routes to the Axum router.
|
||||
///
|
||||
/// This function configures the routes for the web interface, including the
|
||||
/// main item list, individual item details, and static CSS styles.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `app` - The existing Axum router with application state.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// The updated router with web routes added.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let app = pages::add_routes(axum::Router::new());
|
||||
/// ```
|
||||
pub fn add_routes(app: axum::Router<AppState>) -> axum::Router<AppState> {
|
||||
app
|
||||
.route("/", axum::routing::get(list_items))
|
||||
|
||||
Reference in New Issue
Block a user