I've encountered some needs in my projects that currently don't seem to be supported:
-
An option to compress temporary files, for example using gzip.
-
The ability to use a BufRead rather than a Read; this would be more efficient when reading many small items. It's especially useful when using COBS encoding, as BufRead provides read_until() to read up to the next zero byte. However, a BufRead reads more data than necessary and discards it when it goes out of scope, making it difficult to use in Sortable::encode().
-
Support for items whose on-disk size n is constant but only known at runtime. This would allow reading n bytes for each item from the file, without having to store n alongside each item in the file or in memory.
All of this would be feasible with a change in architecture: instead of having Item implement Sortable, ExternalSorter::new could be parameterized by a FileWriterBuilder and a FileReaderBuilder.
I might give this a try, but I’d welcome any feedback first.