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
70
71
use crate::{AdjacencyPage, AdjacencyRequest, NodeProjection, PortError};
/// The coordinator borrows one consistent snapshot for its entire search.
/// Implementations must not open a new transaction per method call.
pub trait TraceSnapshotReader {
/// Canonical bodies in requested order, preserving duplicates and missing slots.
/// Reads must use the same snapshot as node/adjacency. N/E bound object work,
/// not body allocation; a single canonical body may be arbitrarily large.
fn bodies(
&self,
_ids: &[String],
) -> Result<Vec<Option<crate::NodeDetailProjection>>, PortError> {
Err(PortError::Unavailable(
"trace body batches are not supported by this snapshot".into(),
))
}
/// Bodies checked against the digest their descriptor records, over the
/// exact stored bytes, before they are returned.
///
/// Separate from [`bodies`](Self::bodies) because the legacy unbounded
/// read consults no descriptor and must keep working on a store written
/// before descriptors existed. A read that binds cards or expansions to a
/// digest asks for this one: delivering a body the descriptor does not
/// describe would break every binding made against it.
///
/// The default refuses rather than falling back to an unchecked read: a
/// snapshot that cannot verify must not silently answer as if it had.
fn verified_bodies(
&self,
_ids: &[String],
) -> Result<Vec<Option<crate::NodeDetailProjection>>, PortError> {
Err(PortError::Unavailable(
"verified body reads are not supported by this snapshot".into(),
))
}
/// Identity and size of each canonical body, in requested order,
/// preserving duplicates and missing slots, from the same snapshot as
/// `bodies`, `cards` and `adjacency`.
///
/// `None` in a slot means the store holds no body for that ref. A stored
/// body whose descriptor is missing is an inconsistent projection and must
/// fail here: it is never reported as an absent body, and never licenses
/// loading the whole record instead. No implementation may read the body
/// value to answer this.
fn descriptors(
&self,
_ids: &[String],
) -> Result<Vec<Option<crate::NodeBodyDescriptor>>, PortError> {
Err(PortError::Unavailable(
"body descriptors are not supported by this snapshot".into(),
))
}
/// Reader-authored cards in requested order, preserving duplicates and
/// missing slots, from the same snapshot as bodies and adjacency. A
/// snapshot that stores no cards answers every slot `None`, which reads as
/// "no card", never as an error: a compact presentation that cannot find a
/// card still returns its node.
fn cards(
&self,
_ids: &[String],
_language: &str,
) -> Result<Vec<Option<crate::NodeCard>>, PortError> {
Ok(vec![None; _ids.len()])
}
fn node(&self, id: &str) -> Result<Option<NodeProjection>, PortError>;
fn adjacency(&self, request: &AdjacencyRequest) -> Result<AdjacencyPage, PortError>;
}