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
// SPDX-License-Identifier: Apache-2.0
pub use PlainMmapBacking;
/// Storage abstraction for HNSW vector data.
///
/// Two implementations coexist:
/// - [`PlainMmapBacking`]: zero-copy mmap of a plaintext NDVS file (Origin).
/// - `PagedbBacking`: encrypted segment read via pagedb (Lite, task 2a.2).
///
/// Implementations are responsible for vector retrieval; HNSW graph traversal
/// makes no storage-level decisions.
///
/// # `Send + Sync` bound
///
/// The bound allows consumers to park the backing in an
/// `Arc<dyn VectorSegmentBacking>` and dispatch across tasks. Lite will
/// require this in task 2a.2.
///
/// # Return type for `get_vector`
///
/// `-> Option<&[f32]>` borrows from `&self`. This is correct for
/// `PlainMmapBacking` (slice into mmap region lives as long as the backing)
/// and for the planned `PagedbBacking` (which will hold a long-lived
/// decrypted vector slab in a `MmapView` field on `self`).
///
/// If a future backing genuinely cannot return a `&self`-lifetime slice
/// without copying, the signature can be changed to `Cow<'_, [f32]>` in a
/// follow-up refactor. For now both known impls support the zero-copy path.