Skip to main content

PageItem

Struct PageItem 

Source
pub struct PageItem {
    pub path: Vec<Seg>,
    pub label: String,
    pub vkind: VKind,
    pub preview: String,
    pub kind: ItemKind,
    pub inset: usize,
    pub title: Option<String>,
    pub descend_to: Vec<Seg>,
    pub demoted: bool,
    pub summary: Option<String>,
}
Expand description

One line of a page.

Fields§

§path: Vec<Seg>

The fig path to this node from the document root — the same currency tree deals in, so an edit op takes it unchanged.

§label: String

The mapping key, or [i] for a sequence item.

§vkind: VKind§preview: String

A one-line rendering of the value (the scalar text, or {n} / [n]).

§kind: ItemKind§inset: usize

0 for a direct child of the page’s focus; 1 for a member of a group inlined into it, and one more for each further rank the InlineBudget admitted. Bounded by InlineBudget::depth, so the default budget never goes past 1.

§title: Option<String>

A readable stand-in for a sequence item’s index — the value of whichever of its fields best names it (title_keys). None for a mapping entry, whose key already names it, and for an item nothing distinguishes.

It never replaces label: the index is what the path is addressed by and what a reorder moves, so a frontend shows both.

§descend_to: Vec<Seg>

Where opening this row lands, when the pages between here and there would each list nothing but the next step down.

Equal to path for almost every row. It differs for a compressed drill — exports › journal, one row standing for a chain of containers that hold only each other — where it is the deepest of them, the first one whose page has something to say.

path stays the outermost node, so every op still takes it unchanged and none of them needed a special case: deleting the row removes the whole chain (which is what deleting something called exports › journal should do, and leaves no empty husk behind), and renaming it renames exports. Only opening looks here.

§demoted: bool

Whether this item belongs below the fields a reader came here to edit — a page’s own “advanced” section, in the sense a settings menu means it.

Set by the embedder’s demoted-key set, and root-scoped exactly as build_page’s hiding is: it is a property of the whole subtree under a top-level key, so every item on a demoted container’s page is demoted too and the section cannot come apart when you drill into it.

A demotion, not a hiding and not a lock: the item renders, carries its path, and takes every op the others take. It says only that a reader scanning for the field they meant to change should not have to read past this one to find it.

§summary: Option<String>

A container’s entire contents in flow form ({branches: [main]}), when they are short enough to be worth showing instead of counting.

1 field › is strictly less than the document says: the field is right there and it fits. A count is what you fall back to when the contents don’t (SUMMARY_BUDGET), not the default way to describe a small container. None for a scalar, whose value is already its own row.

Implementations§

Source§

impl PageItem

Source

pub fn is_drill(&self) -> bool

Whether activating this item opens a page (rather than editing a value).

A group header does not, though it names a container: its members are already on this page, so the page it would open shows exactly what you can already see — the same two rows twice, once on each side of a split. A container is worth a page when the page tells you something; this one cannot. Its members are reached by moving onto them, and every op that takes the group itself takes a path, which the header still carries.

Source

pub fn is_container(&self) -> bool

Whether this item names a container at all — a drill row, or the header of a group inlined into this page.

Source

pub fn is_scalar(&self) -> bool

Source

pub fn can_rename(&self) -> bool

Whether this item’s label can be changed — true for a mapping entry, false for a sequence item.

A sequence item’s label is its index: it is the position, not a name, so there is nothing to rename and the only thing that moves it is a reorder. The inference is one line, which is exactly why it belongs here — every frontend that redid it would be one edit away from disagreeing with the op that actually refuses.

Source

pub fn is_compressed(&self) -> bool

Whether this row stands for a chain of containers rather than for one (descend_to).

Source

pub fn chain_labels(&self) -> Vec<String>

The names this row shows, outermost first — ["exports", "journal"] for a compressed drill, and just the label for every other row. A frontend joins them with whatever separator its breadcrumb uses.

Trait Implementations§

Source§

impl Clone for PageItem

Source§

fn clone(&self) -> PageItem

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PageItem

Source§

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

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.