diff --git a/CHANGELOG.md b/CHANGELOG.md index 9213922..4a503bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +### Added +* `Copy`, `Clone` and `Hash` on error & event types (where possible) ### Changed * The MSRV has been updated to 1.81.0 due to `core::error::Error` being implemented * **BREAKING**: the features `use_alloc` and `use_heapless` have been renamed to `alloc` and `heapless` respectively. diff --git a/src/accelerometer_event.rs b/src/accelerometer_event.rs index 51f5fef..88ceda8 100644 --- a/src/accelerometer_event.rs +++ b/src/accelerometer_event.rs @@ -3,7 +3,7 @@ use super::{try_f32_from_le_bytes, ProtocolParseError}; /// Represents an accelerometer event from the protocol. -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Debug, Copy, Clone)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[allow(missing_docs)] // the names are already obvious enough diff --git a/src/button_event.rs b/src/button_event.rs index 3e07f37..311e0fe 100644 --- a/src/button_event.rs +++ b/src/button_event.rs @@ -5,7 +5,7 @@ use core::error::Error; use core::fmt::{Display, Formatter}; /// Errors which can be raised while parsing a button event. -#[derive(PartialEq, Eq, Debug)] +#[derive(PartialEq, Eq, Debug, Hash, Clone, Copy)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum ButtonParseError { /// The message contained an unknown button. For the known buttons see [`Button`]. @@ -27,7 +27,7 @@ impl Display for ButtonParseError { impl Error for ButtonParseError {} /// Lists all possible buttons which can be sent in the event. -#[derive(PartialEq, Eq, Debug)] +#[derive(PartialEq, Eq, Debug, Copy, Clone, Hash)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[allow(missing_docs)] // the names are already obvious enough pub enum Button { @@ -59,7 +59,7 @@ impl Button { } /// The state of the button. -#[derive(PartialEq, Eq, Debug)] +#[derive(PartialEq, Eq, Debug, Copy, Clone, Hash)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[allow(missing_docs)] // the names are already obvious enough @@ -80,7 +80,7 @@ impl ButtonState { } /// Represents a button event from the protocol. -#[derive(PartialEq, Eq, Debug)] +#[derive(PartialEq, Eq, Debug, Copy, Clone, Hash)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[allow(missing_docs)] // the names are already obvious enough pub struct ButtonEvent { diff --git a/src/color_event.rs b/src/color_event.rs index 386f4d6..0f1070b 100644 --- a/src/color_event.rs +++ b/src/color_event.rs @@ -5,7 +5,7 @@ use super::ProtocolParseError; use rgb::RGB8; /// Represents a color event from the protocol. -#[derive(PartialEq, Eq, Debug)] +#[derive(PartialEq, Eq, Debug, Copy, Clone, Hash)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[allow(missing_docs)] // the names are already obvious enough diff --git a/src/gyro_event.rs b/src/gyro_event.rs index a081fde..6c2ee51 100644 --- a/src/gyro_event.rs +++ b/src/gyro_event.rs @@ -3,7 +3,7 @@ use super::{try_f32_from_le_bytes, ProtocolParseError}; /// Represents a gyro event from the protocol. -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Debug, Copy, Clone)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[allow(missing_docs)] // the names are already obvious enough diff --git a/src/lib.rs b/src/lib.rs index 9628358..a977292 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -76,7 +76,7 @@ use magnetometer_event::MagnetometerEvent; use quaternion_event::QuaternionEvent; /// Lists all (supported) events which can be sent by the controller. These come with the parsed event data and are the result of a [`parse`] call. -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Debug, Copy, Clone)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[allow(missing_docs)] // the names are already obvious enough pub enum ControllerEvent { @@ -97,7 +97,7 @@ pub enum ControllerEvent { } /// Represents the different kinds of errors which can happen when the protocol is being parsed. -#[derive(PartialEq, Eq, Debug)] +#[derive(PartialEq, Eq, Debug, Copy, Clone, Hash)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum ProtocolParseError { /// The message contained an event which is not known to the current implementation. @@ -157,7 +157,7 @@ impl Error for ProtocolParseError { } /// Lists all data packages which can be sent by the controller. Internal state used during parsing. Use [`ControllerEvent`] to return the actual event. -#[derive(PartialEq, Eq, Debug)] +#[derive(PartialEq, Eq, Debug, Hash, Clone, Copy)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[allow(missing_docs)] // the names are already obvious enough pub enum ControllerDataPackageType { diff --git a/src/location_event.rs b/src/location_event.rs index 8095dc7..cd798b2 100644 --- a/src/location_event.rs +++ b/src/location_event.rs @@ -3,7 +3,7 @@ use super::{try_f32_from_le_bytes, ProtocolParseError}; /// Represents a location event from the protocol. -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Debug, Copy, Clone)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[allow(missing_docs)] // the names are already obvious enough diff --git a/src/magnetometer_event.rs b/src/magnetometer_event.rs index b4fd063..56bc7cf 100644 --- a/src/magnetometer_event.rs +++ b/src/magnetometer_event.rs @@ -3,7 +3,7 @@ use super::{try_f32_from_le_bytes, ProtocolParseError}; /// Represents a magnetometer event from the protocol. -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Debug, Copy, Clone)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[allow(missing_docs)] // the names are already obvious enough diff --git a/src/quaternion_event.rs b/src/quaternion_event.rs index 379eb2c..640c887 100644 --- a/src/quaternion_event.rs +++ b/src/quaternion_event.rs @@ -3,7 +3,7 @@ use super::{try_f32_from_le_bytes, ProtocolParseError}; /// Represents a [quaternion](https://en.wikipedia.org/wiki/Quaternion) event from the protocol. -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Debug, Copy, Clone)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[allow(missing_docs)] // the names are already obvious enough