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 {
new() -> io::Result<MmapInner>12 fn new() -> io::Result<MmapInner> {
13 Err(io::Error::new(
14 io::ErrorKind::Other,
15 "platform not supported",
16 ))
17 }
18
map(_: usize, _: &File, _: u64, _: bool) -> io::Result<MmapInner>19 pub fn map(_: usize, _: &File, _: u64, _: bool) -> io::Result<MmapInner> {
20 MmapInner::new()
21 }
22
map_exec(_: usize, _: &File, _: u64, _: bool) -> io::Result<MmapInner>23 pub fn map_exec(_: usize, _: &File, _: u64, _: bool) -> io::Result<MmapInner> {
24 MmapInner::new()
25 }
26
map_mut(_: usize, _: &File, _: u64, _: bool) -> io::Result<MmapInner>27 pub fn map_mut(_: usize, _: &File, _: u64, _: bool) -> io::Result<MmapInner> {
28 MmapInner::new()
29 }
30
map_copy(_: usize, _: &File, _: u64, _: bool) -> io::Result<MmapInner>31 pub fn map_copy(_: usize, _: &File, _: u64, _: bool) -> io::Result<MmapInner> {
32 MmapInner::new()
33 }
34
map_copy_read_only(_: usize, _: &File, _: u64, _: bool) -> io::Result<MmapInner>35 pub fn map_copy_read_only(_: usize, _: &File, _: u64, _: bool) -> io::Result<MmapInner> {
36 MmapInner::new()
37 }
38
map_anon(_: usize, _: bool, _: bool) -> io::Result<MmapInner>39 pub fn map_anon(_: usize, _: bool, _: bool) -> io::Result<MmapInner> {
40 MmapInner::new()
41 }
42
flush(&self, _: usize, _: usize) -> io::Result<()>43 pub fn flush(&self, _: usize, _: usize) -> io::Result<()> {
44 match self.never {}
45 }
46
flush_async(&self, _: usize, _: usize) -> io::Result<()>47 pub fn flush_async(&self, _: usize, _: usize) -> io::Result<()> {
48 match self.never {}
49 }
50
make_read_only(&mut self) -> io::Result<()>51 pub fn make_read_only(&mut self) -> io::Result<()> {
52 match self.never {}
53 }
54
make_exec(&mut self) -> io::Result<()>55 pub fn make_exec(&mut self) -> io::Result<()> {
56 match self.never {}
57 }
58
make_mut(&mut self) -> io::Result<()>59 pub fn make_mut(&mut self) -> io::Result<()> {
60 match self.never {}
61 }
62
63 #[inline]
ptr(&self) -> *const u864 pub fn ptr(&self) -> *const u8 {
65 match self.never {}
66 }
67
68 #[inline]
mut_ptr(&mut self) -> *mut u869 pub fn mut_ptr(&mut self) -> *mut u8 {
70 match self.never {}
71 }
72
73 #[inline]
len(&self) -> usize74 pub fn len(&self) -> usize {
75 match self.never {}
76 }
77 }
78
file_len(file: &File) -> io::Result<u64>79 pub fn file_len(file: &File) -> io::Result<u64> {
80 Ok(file.metadata()?.len())
81 }
82