Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Adding Data

Once your columns are set up, you populate the table by adding lines and setting cell data. Each line is a row that holds one cell per column. Lines are referenced by opaque LineId handles, which you get back when creating a line and use to read or modify it later.

Lines

Lines are rows in the table. Each line holds one cell per column.

#![allow(unused)]
fn main() {
let row = table.new_line(None); // None = no parent (top-level row)
table.line_mut(row).data_set(0, "sda").data_set(1, "100G");
}

The data_set calls are chainable. Column indices are zero-based and match the order columns were added.

Reading data back

#![allow(unused)]
fn main() {
let name = table.line(row).data_get(0); // Some("sda")
let missing = table.line(row).data_get(99); // None
}

Cells

Each cell can also carry metadata:

#![allow(unused)]
fn main() {
let line = table.line_mut(row);
line.cell_mut(0).unwrap().style_set(CellStyle::new().fg(Color::Red));
line.cell_mut(0).unwrap().uri_set("https://example.com");
}

Line handles

new_line returns a LineId — an opaque handle. You can’t construct one by accident, which prevents indexing bugs.

Iterating

You can walk over all lines in the table, or just the root lines (those without a parent). This is useful for filtering, exporting, or building a second table from an existing one.

#![allow(unused)]
fn main() {
// All lines
for id in table.line_ids() {
    let data = table.line(id).data_get(0);
}

// Root lines only (no parent)
for id in table.root_line_ids() {
    // ...
}
}