How to implement the Reader interface?

The only one that is strictly needed is stream. There are defaults available for the other ones which you can use.


I’ve done something similar before with a zero copy mmap approach and basically settled on using an empty buffer in the interface. This way everything just operates directly on the mapped file. You then may have to change some of the other vtable functions and likely disallow rebasing as it’s not really applicable. See this post which is somewhat similar.

But if the memory and file sizes allow it I would likely just let the operating system map it in and do madvise with MADV_DONTNEED or just munmap it entirely. This can save some headaches.