Skip to main content

page_items

Function page_items 

pub fn page_items(
    items: &[String],
    offset: i64,
    limit: u32,
    unit: &str,
    empty: &str,
    end_unit: &str,
    end_notes: &[&str],
) -> Result<String, PageError>
Expand description

The page of items (one line each, already escaped) for offset (negative: from the end) and limit, as text: the items, then the final line. unit names the items (entries, paths, matches) in [more: ...], end_unit in [end: N <end_unit>] (it may say more, as matches in 3 files) and end_notes go after it; no items give empty and [end: 0 <end_unit>].

At most limit items and PAGE_BYTES of them are shown (the first always), and the next offset is that of the first item not shown. An item over MAX_ITEM_BYTES is cut (clip_item).

ยงErrors

PageError::PastEnd when the list has items and the offset is after the last one.