FaiParser
Mojo struct 🡭
FaiParser
Section titled “FaiParser”@memory_onlystruct FaiParser[R: Reader]Streaming parser for .fai index files over a Reader.
API:
- next_view() → FaiView (zero-alloc; invalidated on next advance)
- next_record() → FaiRecord (materialized; raises EOFError when exhausted)
- for rec in parser / records() → FaiRecord (standard iteration)
- for view in parser.views() → FaiView (zero-alloc iteration)
- collect() → List[FaiRecord] (helper that reads the whole index)
Aliases
Section titled “Aliases”IteratorType[origin: Origin]: AnyStruct[_FaiParserRecordIter[R, origin]] = _FaiParserRecordIter[R, origin]
Parameters
Section titled “Parameters”- R (
Reader)
Implemented traits
Section titled “Implemented traits”AnyType, ImplicitlyDestructible, Iterable, Movable
Methods
Section titled “Methods”__init__
Section titled “__init__”def __init__(out self, var reader: R)Args:
- reader (
R) - self (
Self)
Returns:
Self
Raises:
has_more
Section titled “has_more”def has_more(self) -> BoolArgs:
- self (
Self)
Returns:
Bool
next_view
Section titled “next_view”def next_view(mut self) -> FaiView[MutExternalOrigin]Return the next FAI index row as a zero-alloc FaiView.
The view borrows from the reader’s buffer and is invalidated on the
next call to any advancing method. Call .to_record() when you need
an owned FaiRecord.
Args:
- self (
Self)
Returns:
FaiView
Raises:
EOFError: When no more records are available. Error: On malformed input (wrong column count, non-integer fields).
next_record
Section titled “next_record”def next_record(mut self) -> FaiRecordReturn the next FAI index row as a FaiRecord.
Convenience wrapper around next_view().to_record().
Args:
- self (
Self)
Returns:
FaiRecord
Raises:
EOFError: When no more records are available. Error: On malformed input (wrong column count, non-integer fields).
collect
Section titled “collect”def collect(mut self) -> List[FaiRecord]Read all rows from this index into memory.
Args:
- self (
Self)
Returns:
List
Raises:
def views(ref self) -> _FaiParserViewIter[R, origin_of(self)]Iterator yielding zero-alloc FaiViews.
Args:
- self (
Self)
Returns:
_FaiParserViewIter
records
Section titled “records”def records(ref self) -> _FaiParserRecordIter[R, origin_of(self)]Iterator yielding owned FaiRecords.
Args:
- self (
Self)
Returns:
_FaiParserRecordIter
__iter__
Section titled “__iter__”def __iter__(ref self) -> _FaiParserRecordIter[R, origin_of(self)]Args:
- self (
Self)
Returns:
_FaiParserRecordIter