Skip to main content

cielo_rs_sdk/models/
mod.rs

1//! Models module containing data structures for API responses and paging.
2//!
3//! This module defines the core data structures used for handling API responses
4//! and pagination in the application.
5
6pub mod feed;
7
8use serde::{Deserialize, Serialize};
9
10/// A generic response struct used for API responses.
11///
12/// # Type Parameters
13///
14/// * `T` - The type of the result field.
15#[derive(Debug, Serialize, Deserialize, Clone)]
16pub struct Response<T> {
17    /// The status of the API response.
18    pub status: String,
19    /// The data field containing the response data.
20    pub data: ResponseData<T>,
21    /// The message field containing additional information or context.
22    pub message: Option<String>,
23}
24
25/// A struct representing the data field in the API response.
26///
27/// # Type Parameters
28///
29/// * `T` - The type of the items field.
30#[derive(Debug, Serialize, Deserialize, Clone)]
31pub struct ResponseData<T> {
32    /// A vector of items of type `T`.
33    pub items: Vec<T>,
34    /// The paging information for the response data.
35    pub paging: Paging,
36}
37
38/// A struct representing the paging information in the API response.
39#[derive(Debug, Serialize, Deserialize, Clone)]
40pub struct Paging {
41    /// The total number of rows in the current page.
42    pub total_rows_in_page: u64,
43    /// Indicates if there is a next page.
44    pub has_next_page: bool,
45    /// The object ID for the next page, if available.
46    pub next_object: Option<String>,
47}