Debian Codegraph @

third_party/rust/memmap2/src/stub.rs

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