# How to implement the Reader interface?

**URL:** <https://ziggit.dev/t/how-to-implement-the-reader-interface/17163>\
**Category:** Help\
**Tags:** language, memory-management, standard-library\
**Created:** [August 10, 2026, 10:27am UTC](https://ziggit.dev/t/how-to-implement-the-reader-interface/17163 "2026-08-10T10:27:32Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![pzittlau](https://ziggit.dev/letter_avatar_proxy/v4/letter/p/ecae2f/32.png) [@pzittlau](https://ziggit.dev/u/pzittlau)\
**Post date:** [August 10, 2026, 10:47am UTC](https://ziggit.dev/t/how-to-implement-the-reader-interface/17163/6 "2026-08-10T10:47:42Z")

</div>

> [@pierrelgol](#):
>
> The thing that I want to know, is what is the minimal set of functions to implement a Reader ?

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](https://ziggit.dev/t/implementing-a-zero-copy-block-cache-reader-with-current-rebase-semantics/16216) 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.

---

_[View the full topic](https://ziggit.dev/t/how-to-implement-the-reader-interface/17163)._
