From 51c64b56b015e5971fa399275f60e7b52955708a Mon Sep 17 00:00:00 2001 From: Avril Date: Sun, 23 Oct 2022 05:49:18 +0100 Subject: [PATCH] Made MappedFile impl Send. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added AsRef/Mut<[u8]> impl for MappedFile Fortune for mapped-file's current commit: Half blessing − 半吉 --- Cargo.toml | 2 +- src/lib.rs | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 0808cff..a99239f 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.3" +version = "0.0.4" edition = "2021" repository="https://github.com/notflan/mapped-file" license="MIT" diff --git a/src/lib.rs b/src/lib.rs index 28d2998..870fe31 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -57,6 +57,9 @@ use err::{ #[repr(transparent)] struct MappedSlice(UniqueSlice); +unsafe impl Send for MappedSlice{} +unsafe impl Sync for MappedSlice{} + impl ops::Drop for MappedSlice { #[inline] @@ -631,6 +634,24 @@ impl BorrowMut<[u8]> for MappedFile } } +impl AsRef<[u8]> for MappedFile +{ + #[inline] + fn as_ref(&self) -> &[u8] + { + self.as_slice() + } +} + +impl AsMut<[u8]> for MappedFile +{ + #[inline] + fn as_mut(&mut self) -> &mut [u8] + { + self.as_slice_mut() + } +} + impl ops::Deref for MappedFile { type Target= [u8];