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

State Names

State names are validated at every entry point: when you create an iterator with a name, load a state, delete a state, or call any other registry method. A name that violates the rules raises a NameError in Rust and a ValueError in Python

Rules

  • Names must not be empty
  • Names must not start with / or contain .. (path traversal)
  • Maximum total length: 512 UTF-8 bytes
  • Maximum filename part length: 219 UTF-8 bytes
  • Maximum directory part length: 255 UTF-8 bytes
  • Directory parts cannot end with . or a space
  • Parts cannot be . or Windows reserved device names: CON, PRN, AUX, NUL, CONIN$, CONOUT$, COM1-COM9, COM¹-COM³, LPT1-LPT9, LPT¹-LPT³
  • The characters \ : * ? " < > | are not allowed

These rules apply on all platforms, not just Windows. A state file created on Linux can be read on macOS or Windows without issues

Hierarchical Names

A / in a state name creates subdirectories in the state directory. For example, the name "batch/2024/job-1" stores the state file at <state_dir>/batch/2024/job-1.state.json

Rust

let lines = reader.lines("data.txt")
    .state("batch/2024/job-1")
    .build()?;

Python

lines = reader.lines("data.txt", state="batch/2024/job-1")

You can organize states by project, date, or any other grouping

Examples of Invalid Names

NameReason
""Empty
"../secret"Path traversal (..)
"/absolute"Starts with /
"CON"Windows reserved device name
"job:1"Contains reserved character :
"aaa...a" (513 bytes)Exceeds 512-byte limit