pub struct Snapshot<'s> { /* private fields */ }Expand description
A pinned, immutable read view of the store.
Implementations§
Source§impl<'s> Snapshot<'s>
impl<'s> Snapshot<'s>
Sourcepub fn generation(&self) -> u64
pub fn generation(&self) -> u64
The base generation this snapshot pins.
Sourcepub fn node(&self, key: UrlKey) -> Option<NodeRef<'_>>
pub fn node(&self, key: UrlKey) -> Option<NodeRef<'_>>
Look up a node by durable key, merging base and overlay state.
Sourcepub fn for_each_live<'a>(&'a self, f: impl FnMut(NodeRef<'a>))
pub fn for_each_live<'a>(&'a self, f: impl FnMut(NodeRef<'a>))
Visit every live node (base then overlay-fresh, both in key order for determinism where it matters to callers).
Sourcepub fn neighbors(&self, key: UrlKey) -> Neighbors<'_>
pub fn neighbors(&self, key: UrlKey) -> Neighbors<'_>
Outbound edges of key. Overlay whole-set replacements win over the
base CSR run.
Sourcepub fn in_edges(&self, key: UrlKey, f: impl FnMut(UrlKey, EdgeType, u8, u16))
pub fn in_edges(&self, key: UrlKey, f: impl FnMut(UrlKey, EdgeType, u8, u16))
Inbound edges of key, as (source, type, flags, weight): the
sources whose edge sets point at it. Base runs come from the reverse
index written at compaction; sources whose edges the overlay replaced
or removed are skipped there and reported from the overlay instead.
Sourcepub fn attr(&self, key: UrlKey, k: u8) -> Option<&str>
pub fn attr(&self, key: UrlKey, k: u8) -> Option<&str>
Value of attribute k of key (see crate::Writer::set_attrs).
Sourcepub fn attrs<'a>(&'a self, key: UrlKey, f: impl FnMut(u8, &'a str))
pub fn attrs<'a>(&'a self, key: UrlKey, f: impl FnMut(u8, &'a str))
Every attribute of key, in key order. An overlay whole-set
replacement wins over the base.
Sourcepub fn named_attrs<'a>(&'a self, key: UrlKey, f: impl FnMut(&'a str, &'a str))
pub fn named_attrs<'a>(&'a self, key: UrlKey, f: impl FnMut(&'a str, &'a str))
Every named attribute of key (see crate::Writer::set_named_attrs)
in name order, as (name, value) borrowed from the mmap or overlay.
Records written without a name (crate::Writer::set_attrs) carry
no NUL and are skipped.
Source§impl Snapshot<'_>
impl Snapshot<'_>
Sourcepub fn walk(
&self,
from: UrlKey,
dir: Direction,
max_depth: u32,
follow: impl Fn(EdgeType) -> bool,
w: &mut Walk,
visit: impl FnMut(Hop) -> bool,
)
pub fn walk( &self, from: UrlKey, dir: Direction, max_depth: u32, follow: impl Fn(EdgeType) -> bool, w: &mut Walk, visit: impl FnMut(Hop) -> bool, )
Breadth-first walk from from along edges in dir whose type
follow accepts, at most max_depth hops. visit sees every node
reached once, nearest first, and returns whether to continue past it
(so “the nearest described ancestor” is a walk that stops at
described nodes).
Sourcepub fn walk_both(
&self,
from: UrlKey,
max_depth: u32,
follow: impl Fn(EdgeType) -> bool,
w: &mut Walk,
visit: impl FnMut(Hop) -> bool,
)
pub fn walk_both( &self, from: UrlKey, max_depth: u32, follow: impl Fn(EdgeType) -> bool, w: &mut Walk, visit: impl FnMut(Hop) -> bool, )
crate::Snapshot::walk along outbound and inbound edges at once: the
lineage neighbourhood of a node (what it derives from and what derives
from it, and so on outwards). Each node is reached once, at its
shortest distance over either direction; a node’s outbound edges are
offered before its inbound ones.