diff --git a/Cargo.toml b/Cargo.toml index 9a7a2c3..264e722 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "mapped-file" description = "Construct a memory mapping over any file object" keywords = ["unix", "mmap", "generic", "file", "fd"] -version = "0.0.1" +version = "0.0.2" edition = "2021" repository="https://github.com/notflan/mapped-file" license="MIT" diff --git a/src/file/memory.rs b/src/file/memory.rs index 2628ac1..a02283c 100644 --- a/src/file/memory.rs +++ b/src/file/memory.rs @@ -167,7 +167,7 @@ impl NamedMemoryFile Ok(Self(name, MemoryFile(managed))) } - pub fn with_hugetlb(name: impl AsRef, hugetlb: MapHugeFlag) -> io::Result + pub fn with_hugetlb(name: impl AsRef, hugetlb: MapHugeFlag) -> io::Result { let name: Box = alloc_cstring(name.as_ref()).into(); let memfd = MemoryFile(unsafe { create_raw(&name, DEFAULT_FLAGS | (hugetlb.get_mask() as c_uint)) } diff --git a/src/hugetlb.rs b/src/hugetlb.rs index fb06a6c..ccd92fa 100644 --- a/src/hugetlb.rs +++ b/src/hugetlb.rs @@ -140,6 +140,12 @@ impl From for c_int } } +/// Provides an arbitrary huge-page size and mapping flag for that size. +/// +/// Can store or create a `MAP_HUGE_*` flag for use with `mmap()`, (`MappedFile`) or `memfd_create()` (`file::MemoryFile::with_hugetlb()`) +/// +/// # Usage +/// Main usage is for generating a `MapHugeFlag` via `compute_huge()`. This function may fail (rarely), so a `TryInto` impl exists for `MapHugeFlag` as well. #[derive(Default, Clone, Copy)] pub enum HugePage { /// A staticly presented `MAP_HUGE_*` flag. See `MapHugeFlag` for details.