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
//! Serde helpers for persisting collection-config fields with non-default
//! on-disk representations.
//!
//! The only helper here serializes [`std::time::Duration`] as a whole number
//! of seconds (`u64`). `serde`'s default `Duration` representation is a
//! `{ secs, nanos }` struct, which is verbose and couples the on-disk format
//! to an implementation detail. Persisting seconds keeps `config.json` human
//! readable and stable across `Duration` internals.
//!
//! Sub-second precision is intentionally dropped: every `Duration` carried by
//! [`AutoReindexConfig`](crate::collection::auto_reindex::AutoReindexConfig)
//! is a cooldown measured in whole seconds (default: one hour).
//!
//! # Usage
//!
//! ```ignore
//! use crate::collection::config_serde::duration_secs;
//!
//! #[derive(serde::Serialize, serde::Deserialize)]
//! struct Config {
//! #[serde(with = "duration_secs")]
//! cooldown: std::time::Duration,
//! }
//! ```
/// Serde module persisting a [`Duration`](std::time::Duration) as `u64` seconds.
///
/// Use via `#[serde(with = "crate::collection::config_serde::duration_secs")]`.