pub struct PreviewLayer { /* private fields */ }Implementations§
Source§impl PreviewLayer
impl PreviewLayer
pub fn new() -> Self
Sourcepub fn begin(&mut self, anchor: NodeId) -> u64
pub fn begin(&mut self, anchor: NodeId) -> u64
Supersede any live preview and open a new one anchored at anchor.
Returns the new generation, which the caller must present to fill.
pub fn anchor(&self) -> Option<&NodeId>
pub fn nodes(&self) -> &[Node]
pub fn edges(&self) -> &[Edge]
pub fn aggregates(&self) -> &[Aggregate]
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
How many nodes are provisionally shown. Edge-only and aggregate-only
previews report 0 here but are not is_empty. Deliberately not named
len: pairing a node-only count with an is_empty that also considers
edges and aggregates would violate the usual
is_empty() == (len() == 0) assumption.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the layer holds nothing at all. Note this considers aggregates
as well, so an aggregate-only neighborhood is NOT empty even though
node_count() is 0 — there is something for a host to act on.
Sourcepub fn has_committable(&self) -> bool
pub fn has_committable(&self) -> bool
Whether take_all would actually hand anything back. Distinct from
is_empty(), which also counts aggregates: an aggregate is reported to
a host, never committed into the Graph, so a commit path must ask
this instead.
Sourcepub fn contains(&self, id: &str) -> bool
pub fn contains(&self, id: &str) -> bool
Whether id is among the provisional nodes. Consults nodes only —
an id that appears solely as an edge endpoint is not “contained”.
Sourcepub fn fill(
&mut self,
gen: u64,
res: &NeighborResult,
committed: &Graph,
) -> bool
pub fn fill( &mut self, gen: u64, res: &NeighborResult, committed: &Graph, ) -> bool
Adopt a neighbor result, keeping only what committed lacks. Returns
false and changes nothing when gen is not the live generation, or
when the layer was never begin-ed (a fresh layer’s generation is 0,
which must not be fillable by passing 0).
Replaces rather than appends: a preview is one page of one neighborhood.
Sourcepub fn promote(
&mut self,
id: &str,
committed: &Graph,
) -> Option<(Node, Vec<Edge>)>
pub fn promote( &mut self, id: &str, committed: &Graph, ) -> Option<(Node, Vec<Edge>)>
Move one provisional node out of the layer, along with the incident edges that can safely follow it — those whose other endpoint is already committed (or the node itself, for a self-loop). An edge to another provisional node stays behind rather than dangling.
Sourcepub fn take_all(&mut self) -> (Vec<Node>, Vec<Edge>)
pub fn take_all(&mut self) -> (Vec<Node>, Vec<Edge>)
Drain the committable content (nodes and edges), for an explicit
commit. Retires the generation exactly as clear does — a fetch
still in flight for this preview must not repopulate it after the
fact. The aggregates and the anchor are retained: they are
reported-not-committed offers, and accepting the ghosts is no reason
to withdraw the “expand this group” affordance the host may be
showing. They die with the preview itself (next begin, supersede,
or clear), not with the commit.