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
use std::time::Duration;
/// Per-Lens default policies inherited by every Dio it produces.
#[derive(Debug, Clone)]
pub struct LensDefaults {
/// How often the refresh task fires `on_refresh`. `None` disables
/// scheduled refresh — callers may still invoke `Dio::refresh()`
/// manually.
pub refresh_interval: Option<Duration>,
/// Maximum age a cache entry may reach before counting as stale.
/// `None` means cache entries never expire on their own.
pub cache_ttl: Option<Duration>,
/// Bounded mpsc capacity for the per-Dio write queue. Writes past
/// the cap block the caller — intentional, surfaces overload.
pub write_queue_capacity: usize,
/// When `true`, `make_dio` awaits the `on_start` callback before
/// returning the Dio. When `false`, `on_start` fires in the
/// background and the Dio is returned immediately.
pub on_start_blocking: bool,
/// When `true`, opening a `TableScenery` automatically schedules a
/// `set_viewport(0..page_size)` so the configured `on_load_chunk`
/// re-fetches the first page in the background. Cached rows (if
/// any) are painted immediately, then repainted as the fresh
/// chunk lands. Turn off for read-only / offline modes.
pub refresh_on_open: bool,
/// Window over which rapid `set_viewport` calls are coalesced
/// before a chunk fetch is fired.
pub viewport_debounce: Duration,
}
impl Default for LensDefaults {
fn default() -> Self {
Self {
refresh_interval: None,
cache_ttl: None,
write_queue_capacity: 256,
on_start_blocking: true,
refresh_on_open: true,
viewport_debounce: Duration::from_millis(50),
}
}
}