1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
mod mmap;
mod owned;

pub use crate::{
    mmap::MmapError,
    owned::{OwnedBuffer, OwnedIntoIter},
};

#[cfg(test)]
mod tests {
    use std::{
        fs::File,
        hash::Hash,
        ops::Deref,
        path::{Path, PathBuf},
    };

    use bytes::{Buf, Bytes};

    use super::*;

    #[test]
    fn owned_api() {
        fn static_assert<'a, T>()
        where
            // Conversions
            T: TryFrom<&'a Path, Error = MmapError>,
            T: TryFrom<&'a PathBuf, Error = MmapError>,
            T: TryFrom<PathBuf, Error = MmapError>,
            T: TryFrom<&'a File, Error = MmapError>,
            T: TryFrom<File, Error = MmapError>,
            T: From<&'a Vec<u8>>,
            T: From<&'a [u8]>,
            T: From<Bytes>,
            // PartialEq
            T: PartialEq<[u8]>,
            T: PartialEq<Vec<u8>>,
            T: PartialEq<&'a Vec<u8>>,
            T: PartialEq<&'a [u8]>,
            T: PartialEq<[u8; 42]>,
            [u8]: PartialEq<T>,
            Vec<u8>: PartialEq<T>,
            &'a Vec<u8>: PartialEq<T>,
            &'a [u8]: PartialEq<T>,
            [u8; 42]: PartialEq<T>,
            // Commonly needed for collections
            T: Eq + Ord + Hash,
            // Misc
            T: Deref<Target = [u8]>,
            T: AsRef<[u8]>,
            T: Buf,
            &'a T: IntoIterator<Item = &'a u8> + 'a,
        {
        }

        static_assert::<OwnedBuffer>();
    }
}