Skip to main content

PreviewLayer

Struct PreviewLayer 

Source
pub struct PreviewLayer { /* private fields */ }

Implementations§

Source§

impl PreviewLayer

Source

pub fn new() -> Self

Source

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.

Source

pub fn anchor(&self) -> Option<&NodeId>

Source

pub fn nodes(&self) -> &[Node]

Source

pub fn edges(&self) -> &[Edge]

Source

pub fn aggregates(&self) -> &[Aggregate]

Source

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.

Source

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.

Source

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.

Source

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”.

Source

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.

Source

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.

Source

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.

Source

pub fn clear(&mut self)

Discard without committing. Retires the generation as well: a discard is exactly the case where an in-flight fetch is about to land, and refilling the layer the user just dismissed would be the worst possible outcome.

Trait Implementations§

Source§

impl Debug for PreviewLayer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PreviewLayer

Source§

fn default() -> PreviewLayer

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.