Skip to main content

Page

Struct Page 

Source
pub struct Page {
    pub focus: Vec<Seg>,
    pub items: Vec<PageItem>,
    pub title: Option<String>,
    pub demoted: bool,
}
Expand description

One container’s children, ready to render.

Fields§

§focus: Vec<Seg>

The container being listed. Empty is the document root.

§items: Vec<PageItem>§title: Option<String>

What this page’s own container is called, when it is a sequence item and its index is not worth reading — the same title its row carried on the page you opened it from, so the breadcrumb agrees with what you clicked.

§demoted: bool

Whether this whole page sits under a demoted top-level key.

The page you reach by opening a demoted row. A frontend that folds its demoted items behind an “advanced” disclosure reads this to keep the framing once you are inside — the section a page came out of is still true of the page.

Implementations§

Source§

impl Page

Source

pub fn is_empty(&self) -> bool

Source

pub fn position_of(&self, path: &[Seg]) -> Option<usize>

Where path sits in this page, if it is on it.

A compressed row answers for its whole chain: both the node it is (exports) and the node it opens (exports.journal) find it, because every caller is asking the same question — which row here corresponds to that node — and for a chain the answer is the one row standing for all of it. Identical to matching on the path alone for any row that is not compressed, where the two are the same.

Source

pub fn has_drills(&self) -> bool

Whether any item on this page opens a page of its own.

A page with none is a leaf of the navigation, and — at the root — a document with no depth to navigate at all, which is how a frontend knows to spend the whole width on one pane instead of drawing an empty second one. See Model::pages_would_degenerate.

Source

pub fn has_choice(&self) -> bool

Whether this page offers a choice — two rows or more.

What a pane full of it would be for. A frontend drawing a sidebar reads it to find out whether there is anything to select between: one row is a label, not a menu, and half a screen is a lot to spend on a label.

Source

pub fn partitioned(&self) -> (Vec<&PageItem>, Vec<&PageItem>)

The page’s items in two stable runs: the ones a reader came to edit, then the demoted ones.

items stays in document order, because that order is the document’s and flower does not get to reshuffle it. This is the one rearrangement a settings menu does want — the “advanced” fold — offered here rather than left to each frontend so they all fold at the same seam.

The partition is stable, and demotion is root-scoped, so a group header and the members inlined under it always land in the same run, adjacent and in order: the fold can never cut a group in half.

Source

pub fn breadcrumb(&self, root_label: &str) -> String

The page’s title as a breadcrumb — server › limits, or root_label for the document root.

Trait Implementations§

Source§

impl Clone for Page

Source§

fn clone(&self) -> Page

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 Page

Source§

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

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

impl Default for Page

Source§

fn default() -> Page

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

Auto Trait Implementations§

§

impl Freeze for Page

§

impl RefUnwindSafe for Page

§

impl Send for Page

§

impl Sync for Page

§

impl Unpin for Page

§

impl UnsafeUnpin for Page

§

impl UnwindSafe for Page

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.