| 1 |
use std::fs::File; |
| 2 |
use std::io; |
| 3 |
|
| 4 |
// A stable alternative to https://doc.rust-lang.org/stable/std/primitive.never.html |
| 5 |
enum Never {} |
| 6 |
|
| 7 |
pub struct MmapInner { |
| 8 |
never: Never, |
| 9 |
} |
| 10 |
|
| 11 |
impl MmapInner { |
| 12 |
fn new() -> io::Result<MmapInner> { |
| 13 |
Err(io::ErrorKind::Unsupported.into()) |
| 14 |
} |
| 15 |
|
| 16 |
pub fn map(_: usize, _: &File, _: u64, _: bool, _: bool) -> io::Result<MmapInner> { |
| 17 |
MmapInner::new() |
| 18 |
} |
| 19 |
|
| 20 |
pub fn map_exec(_: usize, _: &File, _: u64, _: bool, _: bool) -> io::Result<MmapInner> { |
| 21 |
MmapInner::new() |
| 22 |
} |
| 23 |
|
| 24 |
pub fn map_mut(_: usize, _: &File, _: u64, _: bool, _: bool) -> io::Result<MmapInner> { |
| 25 |
MmapInner::new() |
| 26 |
} |
| 27 |
|
| 28 |
pub fn map_copy(_: usize, _: &File, _: u64, _: bool, _: bool) -> io::Result<MmapInner> { |
| 29 |
MmapInner::new() |
| 30 |
} |
| 31 |
|
| 32 |
pub fn map_copy_read_only( |
| 33 |
_: usize, |
| 34 |
_: &File, |
| 35 |
_: u64, |
| 36 |
_: bool, |
| 37 |
_: bool, |
| 38 |
) -> io::Result<MmapInner> { |
| 39 |
MmapInner::new() |
| 40 |
} |
| 41 |
|
| 42 |
pub fn map_anon(_: usize, _: bool, _: bool, _: Option<u8>, _: bool) -> io::Result<MmapInner> { |
| 43 |
MmapInner::new() |
| 44 |
} |
| 45 |
|
| 46 |
pub fn flush(&self, _: usize, _: usize) -> io::Result<()> { |
| 47 |
match self.never {} |
| 48 |
} |
| 49 |
|
| 50 |
pub fn flush_async(&self, _: usize, _: usize) -> io::Result<()> { |
| 51 |
match self.never {} |
| 52 |
} |
| 53 |
|
| 54 |
pub fn make_read_only(&mut self) -> io::Result<()> { |
| 55 |
match self.never {} |
| 56 |
} |
| 57 |
|
| 58 |
pub fn make_exec(&mut self) -> io::Result<()> { |
| 59 |
match self.never {} |
| 60 |
} |
| 61 |
|
| 62 |
pub fn make_mut(&mut self) -> io::Result<()> { |
| 63 |
match self.never {} |
| 64 |
} |
| 65 |
|
| 66 |
#[inline] |
| 67 |
pub fn ptr(&self) -> *const u8 { |
| 68 |
match self.never {} |
| 69 |
} |
| 70 |
|
| 71 |
#[inline] |
| 72 |
pub fn mut_ptr(&mut self) -> *mut u8 { |
| 73 |
match self.never {} |
| 74 |
} |
| 75 |
|
| 76 |
#[inline] |
| 77 |
pub fn len(&self) -> usize { |
| 78 |
match self.never {} |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
pub fn file_len(file: &File) -> io::Result<u64> { |
| 83 |
Ok(file.metadata()?.len()) |
| 84 |
} |