Derive and for most enums

This commit is contained in:
Mihai Dinculescu
2022-10-29 15:51:41 +01:00
parent 8cc948816d
commit 0a05fd38c9
7 changed files with 14 additions and 9 deletions

View File

@@ -6,6 +6,11 @@ file. This change log follows the conventions of
## [Unreleased] ## [Unreleased]
### Added
- `#[derive(PartialEq)]` has been added to `Condition`, `DataType`, `FacilityType`, `NotificationGroup`, `Period`, `ViewType`, `ClientEvent`, `SystemEventRequest` and `SystemEvent`.
- `#[derive(Eq)]` has been added to `Condition`, `DataType`, `FacilityType`, `NotificationGroup`, `Period`, `ViewType`, `ClientEvent` and `SystemEventRequest`.
### Changed ### Changed
- The GitHub repository has been renamed from `mihai-dinculescu/simconnect-sdk` to `mihai-dinculescu/simconnect-sdk-rs`. - The GitHub repository has been renamed from `mihai-dinculescu/simconnect-sdk` to `mihai-dinculescu/simconnect-sdk-rs`.

View File

@@ -1,7 +1,7 @@
use crate::bindings; use crate::bindings;
/// Specifies under which conditions the data is to be sent by the server and received by the client. /// Specifies under which conditions the data is to be sent by the server and received by the client.
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum Condition { pub enum Condition {
/// The default, data will be sent strictly according to the defined period. /// The default, data will be sent strictly according to the defined period.
None, None,

View File

@@ -1,5 +1,5 @@
/// [`crate::SimConnectObject`] object property data type. /// [`crate::SimConnectObject`] object property data type.
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum DataType { pub enum DataType {
Float64, Float64,
Bool, Bool,

View File

@@ -3,7 +3,7 @@ use std::os::raw::c_char;
use crate::{bindings, fixed_c_str_to_string, SimConnectError}; use crate::{bindings, fixed_c_str_to_string, SimConnectError};
/// SimConnect System Event Request. /// SimConnect System Event Request.
#[derive(Debug, Copy, Clone, num_enum::TryFromPrimitive)] #[derive(Debug, Copy, Clone, PartialEq, Eq, num_enum::TryFromPrimitive)]
#[repr(u32)] #[repr(u32)]
#[non_exhaustive] #[non_exhaustive]
pub enum SystemEventRequest { pub enum SystemEventRequest {
@@ -84,7 +84,7 @@ impl SystemEventRequest {
} }
/// Cockpit view type. /// Cockpit view type.
#[derive(Debug, Copy, Clone, num_enum::TryFromPrimitive)] #[derive(Debug, Copy, Clone, PartialEq, Eq, num_enum::TryFromPrimitive)]
#[repr(u32)] #[repr(u32)]
pub enum ViewType { pub enum ViewType {
/// No cockpit view. /// No cockpit view.
@@ -98,7 +98,7 @@ pub enum ViewType {
} }
/// SimConnect System Event Notification. /// SimConnect System Event Notification.
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] #[non_exhaustive]
pub enum SystemEvent { pub enum SystemEvent {
/// A notification every second. /// A notification every second.
@@ -274,7 +274,7 @@ pub(crate) const CLIENT_EVENT_START: u32 = 128;
/// SimConnect Client Event. /// SimConnect Client Event.
/// ///
/// WIP. As defined by <https://www.prepar3d.com/SDKv5/sdk/references/variables/event_ids.html>. /// WIP. As defined by <https://www.prepar3d.com/SDKv5/sdk/references/variables/event_ids.html>.
#[derive(Debug, Copy, Clone, num_enum::TryFromPrimitive)] #[derive(Debug, Copy, Clone, PartialEq, Eq, num_enum::TryFromPrimitive)]
#[repr(u32)] #[repr(u32)]
#[non_exhaustive] #[non_exhaustive]
pub enum ClientEvent { pub enum ClientEvent {

View File

@@ -2,7 +2,7 @@ use crate::bindings;
/// Facility Type. The simulation keeps a facilities cache of all the airports, waypoints, NDB and VOR stations within a certain radius of the user aircraft. /// Facility Type. The simulation keeps a facilities cache of all the airports, waypoints, NDB and VOR stations within a certain radius of the user aircraft.
/// They can be requested using [`crate::SimConnect::subscribe_to_facilities`] or [`crate::SimConnect::request_facilities_list`]. /// They can be requested using [`crate::SimConnect::subscribe_to_facilities`] or [`crate::SimConnect::request_facilities_list`].
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum FacilityType { pub enum FacilityType {
Airport, Airport,
Waypoint, Waypoint,

View File

@@ -1,5 +1,5 @@
/// SimConnect event notification group. /// SimConnect event notification group.
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum NotificationGroup { pub enum NotificationGroup {
Group0, Group0,

View File

@@ -5,7 +5,7 @@ use crate::bindings;
/// 1 - every other interval. /// 1 - every other interval.
/// 2 - every third interval. /// 2 - every third interval.
/// etc. /// etc.
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum Period { pub enum Period {
/// Specifies that the data should be sent once only. Note that this is not an efficient way of receiving data frequently, use one of the other periods if there is a regular frequency to the data request. /// Specifies that the data should be sent once only. Note that this is not an efficient way of receiving data frequently, use one of the other periods if there is a regular frequency to the data request.
Once, Once,