fts_core/models/
datetime.rs

1use serde::{Deserialize, Serialize};
2use time::OffsetDateTime;
3use utoipa::{IntoParams, ToSchema};
4
5/// A query type for dealing with datetime ranges
6///
7/// This structure enables API endpoints to accept parameters for filtering results
8/// based on time ranges with optional upper and lower bounds.
9#[derive(Serialize, Deserialize, Debug, ToSchema, IntoParams)]
10pub struct DateTimeRangeQuery {
11    /// The upper bound (exclusive) for the datetime range
12    #[serde(
13        default,
14        with = "time::serde::rfc3339::option",
15        skip_serializing_if = "Option::is_none"
16    )]
17    pub before: Option<OffsetDateTime>,
18
19    /// The lower bound (inclusive) for the datetime range
20    #[serde(
21        default,
22        with = "time::serde::rfc3339::option",
23        skip_serializing_if = "Option::is_none"
24    )]
25    pub after: Option<OffsetDateTime>,
26}
27
28/// The paginated response to a datetime query
29///
30/// This structure provides a standard format for returning time-based paginated results,
31/// including both the results and pagination metadata for retrieving the next page.
32#[derive(Serialize, Deserialize, Debug, ToSchema)]
33pub struct DateTimeRangeResponse<T> {
34    /// The collection of results matching the query
35    pub results: Vec<T>,
36
37    /// Optional pagination metadata for retrieving the next page of results.
38    /// If present, indicates there are more results available.
39    #[serde(skip_serializing_if = "Option::is_none")]
40    pub more: Option<DateTimeRangeQuery>,
41}