Expand description
Bounded reading of one dictionary file into an immutable vocabulary, outside input callbacks.
A personal dictionary is a file that another program, Vim or the OS spell checker, rewrites whenever it likes, so a read can meet a half-written file, a file replaced in the middle of the read, or something at the path that is not a file at all. One observation is:
stat the path a regular file of at most 1 MiB; remember its stamp
open, fstat nonblocking; still a regular file with the same stamp
read at most 1 MiB+1 more than 1 MiB is TooLarge
fstat, stat the path the same stamp through both, and as many bytes as the stamp says
compare with staged same stamp and bytes: publish; otherwise parse and stageA candidate is published only when two consecutive observations read it identically. That settles the usual save patterns but cannot prove a writer finished. Every failure discards the staged candidate and keeps the last published vocabulary, so protection never drops because of one bad read.
Structs§
- Source
- The last published vocabulary of one file plus one staged candidate. It reads only the path it is given and knows no default or home path.
Enums§
- Observation
- Result of one explicitly requested observation; no timer or background task is created.
- Source
Error - Content-free reason an observation failed. The last-good vocabulary remains available.
Type Aliases§
- Parser
- Parses a complete candidate in the source’s word-list format: Vim’s, or a plain list for learned words.