pub struct TableCursor { /* private fields */ }Expand description
Tracks where the next row will be placed within a page.
Created once per table area, then passed to each fit_row call.
Call reset() when starting a new page to restore the cursor to
the top of the new rect. is_first_row() lets the caller detect
a fresh page — useful for repeating a header row.
§Example
let mut cursor = TableCursor::new(&rect);
let mut rows = data.iter().peekable();
while rows.peek().is_some() {
doc.begin_page(612.0, 792.0);
// Repeat header on every page
doc.fit_row(&table, &header, &mut cursor).unwrap();
while let Some(row) = rows.peek() {
match doc.fit_row(&table, row, &mut cursor).unwrap() {
FitResult::Stop => { rows.next(); }
FitResult::BoxFull => break,
FitResult::BoxEmpty => { rows.next(); break; }
}
}
doc.end_page().unwrap();
if rows.peek().is_some() { cursor.reset(&rect); }
}Implementations§
Source§impl TableCursor
impl TableCursor
Sourcepub fn reset(&mut self, rect: &Rect)
pub fn reset(&mut self, rect: &Rect)
Reset to the top of a new rect. Call this when starting a new page.
Sourcepub fn is_first_row(&self) -> bool
pub fn is_first_row(&self) -> bool
Returns true if no rows have been placed on the current page yet.
Use this to detect the start of a new page so you can insert a repeated header row before placing data rows.
Auto Trait Implementations§
impl Freeze for TableCursor
impl RefUnwindSafe for TableCursor
impl Send for TableCursor
impl Sync for TableCursor
impl Unpin for TableCursor
impl UnsafeUnpin for TableCursor
impl UnwindSafe for TableCursor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more