wiithon.fst.serializer module
- class wiithon.fst.serializer.FSTToBytes(fst_entries)[source]
Bases:
objectPre-computed, build-ready representation of a FST.
Unlike
FST.write(), which simply serialises existing offsets, this class is designed for the builder where file data offsets are not known in advance. The string table is computed once at construction time- callback_all_files(callback)[source]
Call the callback for every
FSTFilein depth-first order.- Callback params:
path_parts: the directory path as a list of namesfile_node: theFSTFilenode itself so the caller can mutateoffsetandlengthdirectly
- write_to(stream)[source]
Serialise the FST (raw nodes + string table) to stream at the current position.
File offsets are taken from the
FSTFilenodes as they are at call time, so call this once as a placeholder (offsets=0), write the file data, then call it again with the updated offsets.- Parameters:
stream (
BinaryIO|CryptPartWriter) – Writable binary stream- Return type: