diff --git a/ndk/src/asset.rs b/ndk/src/asset.rs index 4ae0c200..d8dbcee4 100644 --- a/ndk/src/asset.rs +++ b/ndk/src/asset.rs @@ -14,7 +14,7 @@ use std::{ /// A native [`AAssetManager *`] /// /// [`AAssetManager *`]: https://developer.android.com/ndk/reference/group/asset#aassetmanager -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] #[doc(alias = "AAssetManager")] pub struct AssetManager { ptr: NonNull, @@ -92,7 +92,7 @@ impl AssetManager { /// ``` /// /// [`AAssetDir *`]: https://developer.android.com/ndk/reference/group/asset#aassetdir -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] #[doc(alias = "AAssetDir")] pub struct AssetDir { ptr: NonNull, @@ -175,7 +175,7 @@ impl Iterator for AssetDir { /// ``` /// /// [`AAsset *`]: https://developer.android.com/ndk/reference/group/asset#aasset -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] #[doc(alias = "AAsset")] pub struct Asset { ptr: NonNull, diff --git a/ndk/src/audio.rs b/ndk/src/audio.rs index 0be6e1c3..44d9b4d9 100644 --- a/ndk/src/audio.rs +++ b/ndk/src/audio.rs @@ -29,7 +29,7 @@ use crate::utils::abort_on_panic; /// [`android.media.AudioAttributes`]: https://developer.android.com/reference/android/media/AudioAttributes #[cfg(feature = "api-level-29")] #[repr(i32)] -#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[doc(alias = "aaudio_allowed_capture_policy_t")] #[non_exhaustive] pub enum AudioAllowedCapturePolicy { @@ -83,7 +83,7 @@ pub enum AudioAllowedCapturePolicy { /// [`android.media.AudioAttributes`]: https://developer.android.com/reference/android/media/AudioAttributes #[cfg(feature = "api-level-28")] #[repr(i32)] -#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[doc(alias = "aaudio_content_type_t")] #[non_exhaustive] pub enum AudioContentType { @@ -107,7 +107,7 @@ pub enum AudioContentType { } #[repr(i32)] -#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[doc(alias = "aaudio_direction_t")] #[non_exhaustive] pub enum AudioDirection { @@ -124,7 +124,7 @@ pub enum AudioDirection { } #[repr(i32)] -#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[allow(non_camel_case_types)] #[doc(alias = "aaudio_format_t")] #[non_exhaustive] @@ -159,7 +159,7 @@ pub enum AudioFormat { /// Note that these match the equivalent values in MediaRecorder.AudioSource in the Android Java API. #[cfg(feature = "api-level-28")] #[repr(i32)] -#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[doc(alias = "aaudio_input_preset_t")] #[non_exhaustive] pub enum AudioInputPreset { @@ -193,7 +193,7 @@ pub enum AudioInputPreset { } #[repr(i32)] -#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[doc(alias = "aaudio_performance_mode_t")] #[non_exhaustive] pub enum AudioPerformanceMode { @@ -216,7 +216,7 @@ pub enum AudioPerformanceMode { } #[repr(i32)] -#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[doc(alias = "aaudio_sharing_mode_t")] #[non_exhaustive] pub enum AudioSharingMode { @@ -245,7 +245,7 @@ pub enum AudioSharingMode { /// [`android.media.AudioAttributes`]: https://developer.android.com/reference/android/media/AudioAttributes #[cfg(feature = "api-level-28")] #[repr(i32)] -#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[doc(alias = "aaudio_usage_t")] #[non_exhaustive] pub enum AudioUsage { @@ -312,7 +312,7 @@ pub enum AudioUsage { } #[repr(i32)] -#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[doc(alias = "aaudio_stream_state_t")] #[non_exhaustive] pub enum AudioStreamState { @@ -358,21 +358,21 @@ impl AudioStreamState { } } -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "aaudio_session_id_t")] pub enum SessionId { None, Allocated(NonZeroI32), } -#[derive(Copy, Clone, Debug)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct Timestamp { pub frame_position: i64, pub time_nanoseconds: i64, } #[repr(u32)] -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum Clockid { #[doc(alias = "CLOCK_MONOTONIC")] @@ -383,7 +383,7 @@ pub enum Clockid { /// Value returned the data callback function. #[repr(i32)] -#[derive(Copy, Clone, Debug, PartialEq, Eq, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, IntoPrimitive)] #[doc(alias = "aaudio_data_callback_result_t")] #[non_exhaustive] pub enum AudioCallbackResult { @@ -399,7 +399,7 @@ pub enum AudioCallbackResult { } #[repr(i32)] -#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[doc(alias = "aaudio_result_t")] #[non_exhaustive] pub enum AudioError { @@ -983,6 +983,7 @@ impl Drop for AudioStreamBuilder { /// /// [`AAudioStream *`]: https://developer.android.com/ndk/reference/group/audio#aaudiostream #[doc(alias = "AAudioStream")] +// #[derive(Debug, PartialEq, Eq, Hash)] pub struct AudioStream { inner: NonNull, data_callback: Option, diff --git a/ndk/src/bitmap.rs b/ndk/src/bitmap.rs index 6d4d3d7b..b7ddc5e4 100644 --- a/ndk/src/bitmap.rs +++ b/ndk/src/bitmap.rs @@ -16,7 +16,7 @@ use crate::data_space::DataSpace; use crate::hardware_buffer::HardwareBufferRef; #[repr(i32)] -#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[non_exhaustive] pub enum BitmapError { #[doc(alias = "ANDROID_BITMAP_RESULT_ALLOCATION_FAILED")] @@ -90,7 +90,7 @@ pub enum BitmapFormat { /// An immediate wrapper over [`android.graphics.Bitmap`] /// /// [`android.graphics.Bitmap`]: https://developer.android.com/reference/android/graphics/Bitmap -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] pub struct Bitmap { env: *mut JNIEnv, inner: jobject, @@ -299,7 +299,7 @@ impl Bitmap { /// Possible values for [`ffi::ANDROID_BITMAP_FLAGS_ALPHA_MASK`] within [`BitmapInfoFlags`] #[repr(u32)] #[cfg(feature = "api-level-30")] -#[derive(Clone, Copy, Debug, IntoPrimitive, FromPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[doc(alias = "ANDROID_BITMAP_FLAGS_ALPHA_MASK")] #[non_exhaustive] pub enum BitmapInfoFlagsAlpha { @@ -321,7 +321,7 @@ pub enum BitmapInfoFlagsAlpha { /// Bitfield containing information about the bitmap. #[cfg(feature = "api-level-30")] #[repr(transparent)] -#[derive(Clone, Copy, Hash, PartialEq, Eq)] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] pub struct BitmapInfoFlags(u32); #[cfg(feature = "api-level-30")] @@ -359,7 +359,7 @@ impl BitmapInfoFlags { /// A native [`AndroidBitmapInfo`] /// /// [`AndroidBitmapInfo`]: https://developer.android.com/ndk/reference/struct/android-bitmap-info#struct_android_bitmap_info -#[derive(Clone, Copy)] +#[derive(Clone, Copy)] // TODO: PartialEq, Eq, Hash #[doc(alias = "AndroidBitmapInfo")] pub struct BitmapInfo { inner: ffi::AndroidBitmapInfo, @@ -440,7 +440,7 @@ impl BitmapInfo { /// [`Bitmap::compress_raw()`]. #[cfg(feature = "api-level-30")] #[repr(i32)] -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[doc(alias = "AndroidBitmapCompressFormat")] #[non_exhaustive] pub enum BitmapCompressFormat { @@ -477,7 +477,7 @@ pub enum BitmapCompressFormat { /// Encapsulates possible errors returned by [`Bitmap::compress()`] or [`Bitmap::compress_raw()`]. #[cfg(feature = "api-level-30")] -#[derive(Debug, thiserror::Error)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, thiserror::Error)] pub enum BitmapCompressError { #[error(transparent)] BitmapError(#[from] BitmapError), diff --git a/ndk/src/configuration.rs b/ndk/src/configuration.rs index fcd98dda..76a62a3d 100644 --- a/ndk/src/configuration.rs +++ b/ndk/src/configuration.rs @@ -19,6 +19,7 @@ use std::ptr::NonNull; /// [`Configuration`] is an opaque type used to get and set various subsystem configurations. /// /// [`AConfiguration *`]: https://developer.android.com/ndk/reference/group/configuration#aconfiguration +// TODO: Implement hash based on ptr or contents? pub struct Configuration { ptr: NonNull, } @@ -280,7 +281,7 @@ impl Configuration { } /// A bitfield representing the differences between two [`Configuration`]s -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct DiffResult(pub u32); impl DiffResult { @@ -337,7 +338,7 @@ impl DiffResult { } } -#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[repr(i32)] #[non_exhaustive] pub enum Orientation { @@ -351,7 +352,7 @@ pub enum Orientation { __Unknown(i32), } -#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[repr(i32)] #[non_exhaustive] pub enum Touchscreen { @@ -365,7 +366,7 @@ pub enum Touchscreen { __Unknown(i32), } -#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] // TODO: Ord? #[repr(i32)] #[non_exhaustive] pub enum Density { @@ -432,7 +433,7 @@ impl Density { } } -#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[repr(i32)] #[non_exhaustive] pub enum Keyboard { @@ -446,7 +447,7 @@ pub enum Keyboard { __Unknown(i32), } -#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[repr(i32)] #[non_exhaustive] pub enum Navigation { @@ -461,7 +462,7 @@ pub enum Navigation { __Unknown(i32), } -#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[repr(i32)] #[non_exhaustive] pub enum KeysHidden { @@ -475,7 +476,7 @@ pub enum KeysHidden { __Unknown(i32), } -#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[repr(i32)] #[non_exhaustive] pub enum NavHidden { @@ -488,7 +489,7 @@ pub enum NavHidden { __Unknown(i32), } -#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] // TODO: Ord? #[repr(i32)] #[non_exhaustive] pub enum ScreenSize { @@ -503,7 +504,7 @@ pub enum ScreenSize { __Unknown(i32), } -#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[repr(i32)] #[non_exhaustive] pub enum ScreenLong { @@ -516,7 +517,7 @@ pub enum ScreenLong { __Unknown(i32), } -#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[repr(i32)] #[non_exhaustive] pub enum ScreenRound { @@ -529,7 +530,7 @@ pub enum ScreenRound { __Unknown(i32), } -#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[repr(i32)] #[non_exhaustive] pub enum WideColorGamut { @@ -542,7 +543,7 @@ pub enum WideColorGamut { __Unknown(i32), } -#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[repr(i32)] #[non_exhaustive] pub enum HDR { @@ -555,7 +556,7 @@ pub enum HDR { __Unknown(i32), } -#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[repr(i32)] #[non_exhaustive] pub enum LayoutDir { @@ -568,7 +569,7 @@ pub enum LayoutDir { __Unknown(i32), } -#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[repr(i32)] #[non_exhaustive] pub enum UiModeType { @@ -586,7 +587,7 @@ pub enum UiModeType { __Unknown(i32), } -#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[repr(i32)] #[non_exhaustive] pub enum UiModeNight { diff --git a/ndk/src/data_space.rs b/ndk/src/data_space.rs index f25691d1..64b07ae4 100644 --- a/ndk/src/data_space.rs +++ b/ndk/src/data_space.rs @@ -11,7 +11,7 @@ use num_enum::{FromPrimitive, IntoPrimitive}; /// /// #[repr(i32)] -#[derive(Clone, Copy, Hash, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[doc(alias = "ADataSpace")] #[non_exhaustive] pub enum DataSpace { @@ -324,7 +324,7 @@ impl DataSpace { /// defines the chromaticity coordinates of the source primaries in terms of the CIE 1931 definition /// of `x` and `y` specified in ISO 11664-1. #[repr(i32)] -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[doc(alias = "STANDARD_MASK")] #[non_exhaustive] pub enum DataSpaceStandard { @@ -483,7 +483,7 @@ pub enum DataSpaceStandard { /// the `L` component. Implementation may apply the transfer function in `RGB` space for all pixel /// formats if desired. #[repr(i32)] -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[doc(alias = "TRANSFER_MASK")] #[non_exhaustive] pub enum DataSpaceTransfer { @@ -604,7 +604,7 @@ pub enum DataSpaceTransfer { /// Defines the range of values corresponding to the unit range of `0-1`. This is defined for /// `YCbCr` only, but can be expanded to `RGB` space. #[repr(i32)] -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[doc(alias = "RANGE_MASK")] #[non_exhaustive] pub enum DataSpaceRange { diff --git a/ndk/src/event.rs b/ndk/src/event.rs index ef447da4..a83f90ca 100644 --- a/ndk/src/event.rs +++ b/ndk/src/event.rs @@ -19,7 +19,7 @@ use num_enum::{FromPrimitive, IntoPrimitive}; /// A native [`AInputEvent *`] /// /// [`AInputEvent *`]: https://developer.android.com/ndk/reference/group/input#ainputevent -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum InputEvent { MotionEvent(MotionEvent), @@ -29,7 +29,7 @@ pub enum InputEvent { /// Wraps a Java [`InputEvent`] acquired from [`KeyEvent::from_java()`] or /// [`MotionEvent::from_java()`] with respective [`Drop`] semantics. #[cfg(feature = "api-level-31")] -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] pub struct InputEventJava(InputEvent); #[cfg(feature = "api-level-31")] @@ -49,7 +49,7 @@ impl Drop for InputEventJava { } /// An enum representing the source of an [`InputEvent`]. -#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[repr(i32)] #[non_exhaustive] pub enum Source { @@ -86,7 +86,7 @@ impl Source { bitflags::bitflags! { /// Flags representing the class of an [`InputEvent`] [`Source`]. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct SourceClass : u8 { #[doc(alias = "AINPUT_SOURCE_CLASS_BUTTON")] const BUTTON = ffi::AINPUT_SOURCE_CLASS_BUTTON as u8; @@ -149,7 +149,7 @@ impl InputEvent { } /// A bitfield representing the state of modifier keys during an event. -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct MetaState(pub u32); impl MetaState { @@ -231,7 +231,7 @@ impl MetaState { /// javadoc](https://developer.android.com/reference/android/view/MotionEvent). /// /// [`AInputEvent *`]: https://developer.android.com/ndk/reference/group/input#ainputevent -#[derive(Clone, Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] pub struct MotionEvent { ptr: NonNull, } @@ -239,7 +239,7 @@ pub struct MotionEvent { // TODO: thread safety? /// A motion action. -#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[repr(i32)] #[non_exhaustive] pub enum MotionAction { @@ -263,7 +263,7 @@ pub enum MotionAction { } /// An axis of a motion event. -#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[repr(i32)] #[non_exhaustive] pub enum Axis { @@ -319,7 +319,7 @@ pub enum Axis { } /// The tool type of a pointer. -#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[repr(i32)] #[non_exhaustive] pub enum ToolType { @@ -336,7 +336,7 @@ pub enum ToolType { } /// A bitfield representing the state of buttons during a motion event. -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct ButtonState(pub u32); impl ButtonState { @@ -371,7 +371,7 @@ impl ButtonState { } /// A bitfield representing which edges were touched by a motion event. -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct EdgeFlags(pub u32); impl EdgeFlags { @@ -394,7 +394,7 @@ impl EdgeFlags { } /// Flags associated with this [`MotionEvent`]. -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct MotionEventFlags(pub u32); impl MotionEventFlags { @@ -647,7 +647,7 @@ impl MotionEvent { } /// A view into the data of a specific pointer in a motion event. -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] pub struct Pointer<'a> { event: NonNull, index: usize, @@ -735,7 +735,7 @@ impl<'a> Pointer<'a> { } /// An iterator over the pointers in a [`MotionEvent`]. -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] pub struct PointersIter<'a> { event: NonNull, next_index: usize, @@ -773,7 +773,7 @@ impl<'a> ExactSizeIterator for PointersIter<'a> { } /// Represents a view into a past moment of a motion event -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] pub struct HistoricalMotionEvent<'a> { event: NonNull, history_index: usize, @@ -814,7 +814,7 @@ impl<'a> HistoricalMotionEvent<'a> { /// An iterator over all the historical moments in a [`MotionEvent`]. /// /// It iterates from oldest to newest. -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] pub struct HistoricalMotionEventsIter<'a> { event: NonNull, next_history_index: usize, @@ -867,7 +867,7 @@ impl<'a> DoubleEndedIterator for HistoricalMotionEventsIter<'a> { } /// A view into a pointer at a historical moment -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] pub struct HistoricalPointer<'a> { event: NonNull, pointer_index: usize, @@ -1028,7 +1028,7 @@ impl<'a> HistoricalPointer<'a> { } /// An iterator over the pointers in a historical motion event -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] pub struct HistoricalPointersIter<'a> { event: NonNull, history_index: usize, @@ -1076,7 +1076,7 @@ impl ExactSizeIterator for HistoricalPointersIter<'_> { /// javadoc](https://developer.android.com/reference/android/view/KeyEvent). /// /// [`AInputEvent *`]: https://developer.android.com/ndk/reference/group/input#ainputevent -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] pub struct KeyEvent { ptr: NonNull, } @@ -1085,7 +1085,7 @@ pub struct KeyEvent { /// Key actions. /// See [the NDK docs](https://developer.android.com/ndk/reference/group/input#anonymous-enum-27) -#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[repr(i32)] #[non_exhaustive] pub enum KeyAction { @@ -1099,7 +1099,7 @@ pub enum KeyAction { } /// Key codes. -#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[repr(i32)] #[non_exhaustive] pub enum Keycode { @@ -1513,7 +1513,7 @@ impl KeyEvent { } /// Flags associated with [`KeyEvent`]. -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct KeyEventFlags(pub u32); impl KeyEventFlags { diff --git a/ndk/src/font.rs b/ndk/src/font.rs index fc5b1375..ed675391 100644 --- a/ndk/src/font.rs +++ b/ndk/src/font.rs @@ -18,7 +18,7 @@ use num_enum::IntoPrimitive; /// An integer holding a valid font weight value between 1 and 1000. /// /// See the [`Font::weight`] definition for more details. -#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct FontWeight(u16); impl FontWeight { @@ -108,7 +108,7 @@ impl TryFrom for FontWeight { } /// A 4-byte integer representing an OpenType axis tag. -#[derive(Clone, Copy, PartialEq, Eq)] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] pub struct AxisTag(u32); impl AxisTag { @@ -224,7 +224,7 @@ impl fmt::Debug for AxisTag { } /// The error type returned when an invalid axis tag value is passed. -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum AxisTagValueError { /// There is a byte not in the range 0x20 to 0x7E. InvalidCharacter, @@ -257,7 +257,7 @@ impl std::error::Error for AxisTagValueError {} /// A native [`AFont *`] /// /// [`AFont *`]: https://developer.android.com/ndk/reference/group/font -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] pub struct Font { ptr: NonNull, } @@ -390,7 +390,7 @@ impl Drop for Font { /// /// [`AFAMILY_VARIANT_*`]: https://developer.android.com/ndk/reference/group/font#group___font_1gga96a58e29e8dbf2b5bdeb775cba46556ea662aafc7016e35d6758da93416fc0833 #[repr(u32)] -#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, IntoPrimitive)] +#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, IntoPrimitive)] #[non_exhaustive] pub enum FamilyVariant { /// A family variant value for the compact font family variant. @@ -410,7 +410,7 @@ pub enum FamilyVariant { /// A native [`AFontMatcher *`] /// /// [`AFontMatcher *`]: https://developer.android.com/ndk/reference/group/font#afontmatcher_create -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] pub struct FontMatcher { ptr: NonNull, } @@ -510,7 +510,7 @@ impl Drop for FontMatcher { /// A native [`ASystemFontIterator *`] /// /// [`ASystemFontIterator *`]: https://developer.android.com/ndk/reference/group/font#asystemfontiterator_open -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] pub struct SystemFontIterator { ptr: NonNull, } diff --git a/ndk/src/hardware_buffer.rs b/ndk/src/hardware_buffer.rs index e5d4e3e3..9c9ef87a 100644 --- a/ndk/src/hardware_buffer.rs +++ b/ndk/src/hardware_buffer.rs @@ -21,7 +21,7 @@ use super::{hardware_buffer_format::HardwareBufferFormat, utils::status_to_io_re bitflags::bitflags! { /// Buffer usage flags, specifying how the buffer will be accessed. - #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)] + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "AHardwareBuffer_UsageFlags")] pub struct HardwareBufferUsage : u64 { /// The buffer will never be locked for direct CPU reads using the @@ -228,7 +228,7 @@ fn construct(with_ptr: impl FnOnce(*mut T) -> i32) -> Result { /// [`EGL_ANDROID_image_native_buffer`]: https://www.khronos.org/registry/EGL/extensions/ANDROID/EGL_ANDROID_image_native_buffer.txt /// [external memory]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_external_memory.html /// [`VK_ANDROID_external_memory_android_hardware_buffer`]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_ANDROID_external_memory_android_hardware_buffer.html -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] pub struct HardwareBuffer { inner: NonNull, } @@ -531,7 +531,7 @@ impl HardwareBuffer { /// A [`HardwareBuffer`] with an owned reference, that is released when dropped. /// It behaves much like a strong [`std::rc::Rc`] reference. -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] pub struct HardwareBufferRef { inner: HardwareBuffer, } @@ -575,7 +575,7 @@ impl Clone for HardwareBufferRef { /// Buffer description. /// /// Used for allocating new buffers and querying parameters of existing ones. -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct HardwareBufferDesc { pub width: u32, pub height: u32, @@ -607,7 +607,7 @@ impl HardwareBufferDesc { /// Contains the same fields as [`ffi::AHardwareBuffer_Plane`]. /// /// [`AHardwareBuffer_Plane`]: https://developer.android.com/ndk/reference/group/a-hardware-buffer#ahardwarebuffer_plane -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct LockedPlaneInfo { pub virtual_address: *mut c_void, pub bytes_per_pixel: u32, @@ -615,7 +615,7 @@ pub struct LockedPlaneInfo { } /// Iterator over [`ffi::AHardwareBuffer_Planes`], containing a list of [`LockedPlaneInfo`]. -#[derive(Debug)] +#[derive(Debug)] // TODO: Eq and Hash? pub struct HardwareBufferPlanes { inner: ffi::AHardwareBuffer_Planes, index: u32, diff --git a/ndk/src/hardware_buffer_format.rs b/ndk/src/hardware_buffer_format.rs index 555669f5..074ca560 100644 --- a/ndk/src/hardware_buffer_format.rs +++ b/ndk/src/hardware_buffer_format.rs @@ -6,7 +6,7 @@ use num_enum::{FromPrimitive, IntoPrimitive}; /// Buffer pixel formats. #[repr(i32)] -#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[allow(non_camel_case_types)] #[non_exhaustive] pub enum HardwareBufferFormat { diff --git a/ndk/src/input_queue.rs b/ndk/src/input_queue.rs index 6c96228d..18a8fb77 100644 --- a/ndk/src/input_queue.rs +++ b/ndk/src/input_queue.rs @@ -20,7 +20,7 @@ use crate::utils::status_to_io_result; /// An input queue is the facility through which you retrieve input events. /// /// [`AInputQueue *`]: https://developer.android.com/ndk/reference/group/input#ainputqueue -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] pub struct InputQueue { ptr: NonNull, } diff --git a/ndk/src/looper.rs b/ndk/src/looper.rs index d8eb644b..980cdaa2 100644 --- a/ndk/src/looper.rs +++ b/ndk/src/looper.rs @@ -24,7 +24,7 @@ use crate::utils::abort_on_panic; /// current thread. /// /// [`ALooper *`]: https://developer.android.com/ndk/reference/group/looper#alooper -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] pub struct ThreadLooper { _marker: std::marker::PhantomData<*mut ()>, // Not send or sync foreign: ForeignLooper, @@ -34,7 +34,7 @@ bitflags::bitflags! { /// Flags for file descriptor events that a looper can monitor. /// /// These flag bits can be combined to monitor multiple events at once. - #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct FdEvent : u32 { /// The file descriptor is available for read operations. #[doc(alias = "ALOOPER_EVENT_INPUT")] @@ -91,7 +91,7 @@ pub enum Poll<'fd> { }, } -#[derive(Debug, Copy, Clone, Error)] +#[derive(Clone, Copy, Debug, Error)] #[error("Android Looper error")] pub struct LooperError; @@ -260,7 +260,7 @@ impl ThreadLooper { /// A native [`ALooper *`], not necessarily allocated with the current thread. /// /// [`ALooper *`]: https://developer.android.com/ndk/reference/group/looper#alooper -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] pub struct ForeignLooper { ptr: ptr::NonNull, } diff --git a/ndk/src/media/image_reader.rs b/ndk/src/media/image_reader.rs index 2e684cd8..b2360743 100644 --- a/ndk/src/media/image_reader.rs +++ b/ndk/src/media/image_reader.rs @@ -19,7 +19,7 @@ use crate::utils::abort_on_panic; use crate::{data_space::DataSpace, hardware_buffer_format::HardwareBufferFormat}; #[repr(i32)] -#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[allow(non_camel_case_types)] #[non_exhaustive] #[doc(alias = "AIMAGE_FORMATS")] @@ -61,7 +61,7 @@ pub type BufferRemovedListener = Box { /// Returned if there is no buffers currently available in the reader queue. #[doc(alias = "AMEDIA_IMGREADER_NO_BUFFER_AVAILABLE")] @@ -378,7 +378,7 @@ impl Drop for ImageReader { /// A native [`AImage *`] /// /// [`AImage *`]: https://developer.android.com/ndk/reference/group/media#aimage -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] #[doc(alias = "AImage")] pub struct Image { inner: NonNull, diff --git a/ndk/src/media/media_codec.rs b/ndk/src/media/media_codec.rs index 7d6e42ca..e2017d33 100644 --- a/ndk/src/media/media_codec.rs +++ b/ndk/src/media/media_codec.rs @@ -17,7 +17,7 @@ use std::{ time::Duration, }; -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, Hash)] pub enum MediaCodecDirection { Decoder, Encoder, @@ -26,7 +26,7 @@ pub enum MediaCodecDirection { /// A native [`AMediaCodec *`] /// /// [`AMediaCodec *`]: https://developer.android.com/ndk/reference/group/media#amediacodec -#[derive(Debug)] +#[derive(Debug)] // TODO: No eq/hash because of callbacks pub struct MediaCodec { inner: NonNull, async_notify_callback: Option>>, @@ -593,7 +593,7 @@ pub enum DequeuedOutputBufferInfoResult<'a> { OutputBuffersChanged, } -#[derive(Copy, Clone, Debug)] +#[derive(Clone, Copy, Debug)] pub struct BufferInfo { inner: ffi::AMediaCodecBufferInfo, } @@ -616,7 +616,7 @@ impl BufferInfo { } } -#[derive(Copy, Clone, Debug)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct ActionCode(pub i32); impl ActionCode { diff --git a/ndk/src/media/media_format.rs b/ndk/src/media/media_format.rs index 4997d522..a670a24f 100644 --- a/ndk/src/media/media_format.rs +++ b/ndk/src/media/media_format.rs @@ -14,6 +14,7 @@ use crate::media_error::{MediaError, Result}; /// A native [`AMediaFormat *`] /// /// [`AMediaFormat *`]: https://developer.android.com/ndk/reference/group/media#amediaformat +#[derive(PartialEq, Eq, Hash)] #[doc(alias = "AMediaFormat")] pub struct MediaFormat { inner: NonNull, diff --git a/ndk/src/media_error.rs b/ndk/src/media_error.rs index 99fb0d5f..3354d8ba 100644 --- a/ndk/src/media_error.rs +++ b/ndk/src/media_error.rs @@ -14,7 +14,7 @@ pub type Result = std::result::Result; /// Media Status codes for [`media_status_t`](https://developer.android.com/ndk/reference/group/media#group___media_1ga009a49041fe39f7bdc6d8b5cddbe760c) #[repr(i32)] -#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive, IntoPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, FromPrimitive, IntoPrimitive)] #[doc(alias = "media_status_t")] #[non_exhaustive] pub enum MediaError { diff --git a/ndk/src/native_activity.rs b/ndk/src/native_activity.rs index 19c8965e..0f0e3cbd 100644 --- a/ndk/src/native_activity.rs +++ b/ndk/src/native_activity.rs @@ -16,7 +16,7 @@ bitflags::bitflags! { /// /// /// [`android.view.WindowManager.LayoutParams`]: https://developer.android.com/reference/android/view/WindowManager.LayoutParams - #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct WindowFlags : u32 { const ALLOW_LOCK_WHILE_SCREEN_ON = ffi::AWINDOW_FLAG_ALLOW_LOCK_WHILE_SCREEN_ON; const DIM_BEHIND = ffi::AWINDOW_FLAG_DIM_BEHIND; @@ -59,7 +59,7 @@ bitflags::bitflags! { /// `ndk_glue::native_activity()`. /// /// [`ANativeActivity *`]: https://developer.android.com/ndk/reference/struct/a-native-activity -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] pub struct NativeActivity { ptr: NonNull, } diff --git a/ndk/src/native_window.rs b/ndk/src/native_window.rs index 1a339032..fb27dac3 100644 --- a/ndk/src/native_window.rs +++ b/ndk/src/native_window.rs @@ -19,7 +19,7 @@ pub type Rect = ffi::ARect; /// display or sent to other consumers, such as video encoders. /// /// [`android.view.Surface`]: https://developer.android.com/reference/android/view/Surface -#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +#[derive(Debug, PartialEq, Eq, Hash)] pub struct NativeWindow { ptr: NonNull, } @@ -294,7 +294,7 @@ impl NativeWindow { } /// Lock holding the next drawing surface for writing. It is unlocked and posted on [`drop()`]. -#[derive(Debug)] +#[derive(Debug)] // TODO: PartialEq, Eq, Hash pub struct NativeWindowBufferLockGuard<'a> { window: &'a NativeWindow, buffer: ffi::ANativeWindow_Buffer, @@ -385,7 +385,7 @@ bitflags::bitflags! { /// Supported transforms are any combination of horizontal mirror, vertical mirror, and /// clockwise 90 degree rotation, in that order. Rotations of 180 and 270 degrees are made up /// of those basic transforms. - #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)] + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "ANativeWindowTransform")] pub struct NativeWindowTransform : i32 { #[doc(alias = "ANATIVEWINDOW_TRANSFORM_IDENTITY")] @@ -416,7 +416,7 @@ bitflags::bitflags! { /// . #[cfg(all(feature = "nativewindow", feature = "api-level-30"))] #[repr(i8)] -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] // TODO: IntoPrimitive #[doc(alias = "ANativeWindow_FrameRateCompatibility")] #[non_exhaustive] pub enum FrameRateCompatibility { @@ -443,7 +443,7 @@ pub enum FrameRateCompatibility { /// Change frame rate strategy value for [`NativeWindow::set_frame_rate_with_change_strategy()`]. #[cfg(all(feature = "nativewindow", feature = "api-level-31"))] #[repr(i8)] -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] // TODO: IntoPrimitive #[doc(alias = "ANativeWindow_ChangeFrameRateStrategy")] #[non_exhaustive] pub enum ChangeFrameRateStrategy { diff --git a/ndk/src/surface_texture.rs b/ndk/src/surface_texture.rs index 943b949e..6bd37072 100644 --- a/ndk/src/surface_texture.rs +++ b/ndk/src/surface_texture.rs @@ -13,7 +13,7 @@ use std::{io::Result, ptr::NonNull, time::Duration}; /// An opaque type to manage [`android.graphics.SurfaceTexture`] from native code /// /// [`android.graphics.SurfaceTexture`]: https://developer.android.com/reference/android/graphics/SurfaceTexture -#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +#[derive(Debug, PartialEq, Eq, Hash)] pub struct SurfaceTexture { ptr: NonNull, } diff --git a/ndk/src/trace.rs b/ndk/src/trace.rs index 8c6cd6fb..74018aad 100644 --- a/ndk/src/trace.rs +++ b/ndk/src/trace.rs @@ -35,11 +35,11 @@ impl Drop for Section { } /// Unique identifier for distinguishing simultaneous events -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] // TODO: Clone/Copy? #[cfg(feature = "api-level-29")] pub struct Cookie(pub i32); -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash)] #[cfg(feature = "api-level-29")] pub struct AsyncSection { section_name: CString, @@ -74,7 +74,7 @@ impl Drop for AsyncSection { } #[cfg(feature = "api-level-29")] -#[derive(Debug)] +#[derive(Clone, Debug, PartialEq, Eq, Hash)] pub struct Counter { name: CString, }