Alignment
When start falls in the middle of a line or segment, the align option (called align_start in Python) skips the partial first item and begins reading at the next complete item
Without Alignment
A line iterator starting at byte 4 in "hello\nworld\n" yields "o" (the tail of "hello") followed by "world". The first yielded item is a fragment
With Alignment
The same iterator with alignment enabled skips the partial "o\n" and yields only "world", a complete line
Examples
Rust
let lines = reader.lines("data.txt")
.start(4)
.align(true)
.build()?;
Python
from preader import IteratorOptions
options = IteratorOptions(start=4)
lines = reader.lines("data.txt", align_start=True, options=options)
The same option is available on the segment iterator:
Rust
let segments = reader.segments("data.bin")
.start(10)
.delimiter(b',')
.align(true)
.build()?;
Python
options = IteratorOptions(start=10)
segments = reader.segments(
"data.bin", delimiter=b",", align_start=True, options=options
)
Alignment applies only to line and segment iterators. Byte and chunk iterators do not have item boundaries to align to
| Option | Rust Builder Method | Python Keyword |
|---|---|---|
| Align start | align(true) | align_start=True |