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