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

Windowing

Windowing lets you control which portion of a file an iterator reads. You can set a byte range, skip a number of items, limit how many items to yield, or align the start to an item boundary

In Rust, these options are set through builder methods:

reader.lines("data.txt")
    .start(100)
    .end(500)
    .skip(2)
    .limit(10)
    .build()?;

In Python, you pass an IteratorOptions object:

from preader import IteratorOptions

options = IteratorOptions(start=100, end=500, skip=2, limit=10)

reader.lines("data.txt", options=options)

When you use multiple windowing options together, they are applied in this order:

  1. Byte range (start, end) restricts the file region
  2. Alignment (align / align_start) skips the partial first item at start
  3. Skip discards the first N complete items within the range
  4. Limit caps how many items are yielded after skipping

This means skip and limit operate within the byte range, not across the entire file

// Read bytes 100-500, skip the first 2 lines in that range, yield at most 10
reader.lines("data.txt")
    .start(100)
    .end(500)
    .align(true)
    .skip(2)
    .limit(10)
    .build()?;
from preader import IteratorOptions

options = IteratorOptions(start=100, end=500, skip=2, limit=10)

reader.lines("data.txt", align_start=True, options=options)

The following pages explain each option and how they interact

  • ↔️ Byte Range: start and end byte offsets
  • 🔢 Pagination: skip and limit for item-level control
  • 📏 Alignment: Handling a start offset that falls mid-item