fts_core/models/
datetime.rs

1/// A query type for dealing with datetime ranges
2///
3/// This structure enables API endpoints to accept parameters for filtering results
4/// based on time ranges with optional upper and lower bounds.
5#[derive(Debug, Clone, PartialEq)]
6#[cfg_attr(
7    feature = "schemars",
8    derive(schemars::JsonSchema),
9    schemars(rename = "DateTimeRangeQuery")
10)]
11#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12pub struct DateTimeRangeQuery<DateTime> {
13    /// The upper bound (exclusive) for the datetime range
14    #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
15    pub before: Option<DateTime>,
16
17    /// The lower bound (inclusive) for the datetime range
18    #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
19    pub after: Option<DateTime>,
20}
21
22/// The paginated response to a datetime query
23///
24/// This structure provides a standard format for returning time-based paginated results,
25/// including both the results and pagination metadata for retrieving the next page.
26#[derive(Debug, Clone, PartialEq)]
27#[cfg_attr(
28    feature = "schemars",
29    derive(schemars::JsonSchema),
30    schemars(rename = "DateTimeRangeResponse_of_{T}")
31)]
32#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
33pub struct DateTimeRangeResponse<T, DateTime> {
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    #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
40    pub more: Option<DateTimeRangeQuery<DateTime>>,
41}