You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Even though files are the most obvious target for an mmap, we might want to call mmap on a file descriptor that isn't backed by a File. Buffers on Linux can be allocated that way for example.
The current API that takes a File doesn't really allow to use the crate in such a case.
Something that would work would be
let buffer_fd = allocate_buffer(whatever);
let file = unsafe { File::from_raw_fd(buffer_fd) };
let mut mmap = unsafe {
MmapOptions::new().map_mut(&file)?
};
However, FrowRawFd consumes the ownership of the FD, therefore making it fairly hard to integrate into a larger buffer management codebase.
We could switch from File to AsRawFd the API, but I'm not sure whether that change in the API would be welcome?
The text was updated successfully, but these errors were encountered:
Well, we have to support Windows too and AsRawFd is Unix-only. I guess we have to provide some kind of wrapper that would accept File, RawFd and RawHandle. Basically:
Even though files are the most obvious target for an mmap, we might want to call mmap on a file descriptor that isn't backed by a File. Buffers on Linux can be allocated that way for example.
The current API that takes a File doesn't really allow to use the crate in such a case.
Something that would work would be
However, FrowRawFd consumes the ownership of the FD, therefore making it fairly hard to integrate into a larger buffer management codebase.
We could switch from File to AsRawFd the API, but I'm not sure whether that change in the API would be welcome?
The text was updated successfully, but these errors were encountered: