Updates for zerocopy 0.8. am: 4a6d96c168 Original change: https://android-review.googlesource.com/c/platform/system/libfmq/+/3380383 Change-Id: Ie4c4b089b8440d72709e53178a57a62b843504d1 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/Android.bp b/Android.bp index f1b881c..447f977 100644 --- a/Android.bp +++ b/Android.bp
@@ -199,7 +199,7 @@ rustlibs: [ "libfmq_bindgen", "liblog_rust", - "libzerocopy-0.7.35", + "libzerocopy", ], proc_macros: [], }
diff --git a/libfmq.rs b/libfmq.rs index 47c5c15..55a3419 100644 --- a/libfmq.rs +++ b/libfmq.rs
@@ -22,11 +22,11 @@ ndk_ScopedFileDescriptor, ErasedMessageQueue, ErasedMessageQueueDesc, GrantorDescriptor, MQDescriptor, MemTransaction, NativeHandle, ParcelFileDescriptor, SynchronizedReadWrite, }; +use log::error; +use zerocopy::{FromBytes, Immutable, IntoBytes}; use std::ptr::addr_of_mut; -use log::error; - /// A trait indicating that a type is safe to pass through shared memory. /// /// # Safety @@ -40,8 +40,10 @@ /// the same process. As such, `Share` is a supertrait of `Sync`. pub unsafe trait Share: Sync {} -// SAFETY: All types implementing the `zerocopy::AsBytes` trait implement `Share`. -unsafe impl<T: zerocopy::AsBytes + zerocopy::FromBytes + Send + Sync> Share for T {} +// SAFETY: All types implementing the zerocopy `Immutable`, `IntoBytes` and `FromBytes` traits +// implement `Share`, because that implies that they don't have any interior mutability and can be +// treated as just a slice of bytes. +unsafe impl<T: Immutable + IntoBytes + FromBytes + Send + Sync> Share for T {} /// An IPC message queue for values of type T. pub struct MessageQueue<T> {