Memory-mapped IO


I will need memory-mapped IO for reimplementation of libintl I am planning.

Now of course there is libc::funcs::posix88::mman::mmap, which AFACT is available everywhere. The problem is, that the only way to open the file is with libc::funcs::posix88::fcntl::open and that only takes path as narrow string, which on Windows means the legacy codepage which can’t encode all possible file and directory names.

So I’d like to ask whether there is any plan for implementing memory map in standard library?


The old api is deprecated with the message “replaced with std::env APIs” so I assume it will come. No promises on the timeline.


I suppose I can see why it is deprecated:

pub enum MapOption {
    // …
    // …

That’s not much help over libc::funcs::posix88::mman::mmap, because it still uses a file descriptor and not a std::fs::File. And std::fs::File implements unstable std::os::unix::AsRawFd, which I am not sure works on Windows (well, worse problem is that that is unstable and I can’t escape that by using libc from

The message is unfortunately generic for everything deprecated under std::os and it makes no sense for many items.


I guess there is not much of a progress, as I still cannot find anything MemoryMap like in the nightly doc.

I browsed the issues and found someone reporting a bug and someone telling them that mmap is not part of the stdlib anymore but linking to an implementation on GitHub with a corresponding package, just in case you still need that.

EDIT: Sorry to revive this old thread, but it was the only one I found when looking for this, so my post might be helpful to others looking for a MemoryMap implementation.


Unfortunately that library hasn’t been updated in a while. I’ve had a PR sitting around to fix it on Windows since April 13. I think someone else needs to take up the helm of maintaining a memory map crate. I’d be glad to handle the Windows side of such a crate, but someone needs to take care of the non-Windows version.


I don’t know if I have enough time to do that, but I think it would be a great way to improve my Rust coding skills.

So, if you really want to do that, I would be glad to help you.


Actually it turns out someone else has decided to create an mmap library. Hopefully this one is better maintained.