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
64
65
66
67
68
69
//! Core data types and configuration constants for Starshard.
//!
//! This module contains the shared types used across both synchronous and
//! asynchronous map implementations:
//!
//! - [`SnapshotMode`] — controls how iteration snapshots are produced
//! (`Clone`, `Cached`, or `Cow`).
//! - [`ShardStats`] — runtime statistics about shard distribution and load.
//! - [`DEFAULT_SHARDS`] / [`MAX_SHARDS`] — default and upper-bound shard counts.
/// Default shard count (power-of-two not required; hashing modulo used).
pub const DEFAULT_SHARDS: usize = 64;
/// Default hard cap for shard slots in infallible constructors.
///
/// This guards against accidental or attacker-influenced oversized allocations.
/// If you need a different cap, use `with_shards_and_hasher_capped(...)` or
/// `try_with_shards_and_hasher_capped(...)`.
pub const MAX_SHARDS: usize = 262_144;
/// Snapshot construction mode.
/// Statistics about shard distribution and utilization.
///
/// Fields:
/// - `initialized`: number of shards that have been allocated
/// - `total`: total configured shard slots
/// - `empty`: number of initialized shards with zero entries
/// - `avg_load`: average load across initialized shards
/// - `max_load`: maximum load in any shard