1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//! Options for filtered session retrieval.
use chrono::{DateTime, Utc};
/// Options for loading a subset of session entries.
///
/// All fields default to `None`, meaning no filtering is applied and the
/// full session is returned.
///
/// # Examples
///
/// ```rust,ignore
/// let options = LoadOptions::new().with_last_n_entries(10);
/// let (meta, entries) = store.load_with_options("session_id", &options)?;
/// ```
#[non_exhaustive]
#[derive(Debug, Clone, Default)]
pub struct LoadOptions {
/// Return only the last N entries (applied after other filters).
pub last_n_entries: Option<usize>,
/// Return only entries with timestamps after this instant.
pub after_timestamp: Option<DateTime<Utc>>,
/// Return only entries whose `entry_type` discriminator matches one of
/// these strings (e.g., `"message"`, `"model_change"`, `"label"`).
pub entry_types: Option<Vec<String>>,
}
impl LoadOptions {
/// Creates a new `LoadOptions` with no filters applied.
#[must_use]
pub fn new() -> Self {
Self::default()
}
/// Restricts results to the last N entries (applied after other filters).
#[must_use]
pub fn with_last_n_entries(mut self, last_n_entries: usize) -> Self {
self.last_n_entries = Some(last_n_entries);
self
}
/// Restricts results to entries with timestamps after this instant.
#[must_use]
pub fn with_after_timestamp(mut self, after_timestamp: DateTime<Utc>) -> Self {
self.after_timestamp = Some(after_timestamp);
self
}
/// Restricts results to entries whose `entry_type` discriminator matches
/// one of the given strings (e.g., `"message"`, `"model_change"`, `"label"`).
#[must_use]
pub fn with_entry_types(mut self, entry_types: Vec<String>) -> Self {
self.entry_types = Some(entry_types);
self
}
}
const _: () = {
const fn assert_send_sync<T: Send + Sync>() {}
assert_send_sync::<LoadOptions>();
};