Add support for String

This commit is contained in:
Mihai Dinculescu
2022-10-20 15:42:51 +01:00
parent 60b73c1557
commit 4ac94cdb96
21 changed files with 574 additions and 404 deletions

View File

@@ -3,7 +3,7 @@
use simconnect_sdk_derive::SimConnectObject;
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second")]
struct GpsData1 {
struct Data1 {
#[simconnect(name = "PLANE LATITUDE", unit = "degrees")]
pub lat: f64,
#[simconnect(name = "PLANE LONGITUDE", unit = "degrees")]
@@ -12,7 +12,7 @@ struct GpsData1 {
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second", condition = "none")]
struct GpsData2 {
struct Data2 {
#[simconnect(name = "PLANE LATITUDE", unit = "degrees")]
pub lat: f64,
#[simconnect(name = "PLANE LONGITUDE", unit = "degrees")]
@@ -21,7 +21,7 @@ struct GpsData2 {
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "visual-frame", condition = "changed")]
struct GpsData3 {
struct Data3 {
#[simconnect(name = "PLANE LATITUDE", unit = "degrees")]
pub lat: f64,
#[simconnect(name = "PLANE LONGITUDE", unit = "degrees")]
@@ -30,7 +30,7 @@ struct GpsData3 {
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "visual-frame", condition = "changed", interval = 0)]
struct GpsData4 {
struct Data4 {
#[simconnect(name = "PLANE LATITUDE", unit = "degrees")]
pub lat: f64,
#[simconnect(name = "PLANE LONGITUDE", unit = "degrees")]

View File

@@ -3,45 +3,45 @@ use simconnect_sdk_derive::SimConnectObject;
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "visual-frame", condition = "changed")]
struct GpsData1(f64);
struct Data1(f64);
#[derive(Debug, Clone, SimConnectObject)]
struct GpsData2 {}
struct Data2 {}
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect]
struct GpsData3 {}
struct Data3 {}
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect()]
struct GpsData4 {}
struct Data4 {}
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second", period = "second")]
struct GpsData5 {}
struct Data5 {}
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second", condition = "none", condition = "none")]
struct GpsData6 {}
struct Data6 {}
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second", interval = 0, interval = 0)]
struct GpsData7 {}
struct Data7 {}
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second", test = "test")]
struct GpsData8 {}
struct Data8 {}
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(periodX = "second", condition = "none")]
struct GpsData9 {}
struct Data9 {}
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second", conditionX = "none")]
struct GpsData10 {}
struct Data10 {}
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second", intervalX = 0)]
struct GpsData11 {}
struct Data11 {}
fn main() {}

View File

@@ -2,14 +2,14 @@ error: Unsupported field type. Only named fields are supported.
--> tests/02-struct-attr-errors.rs:5:1
|
5 | / #[simconnect(period = "visual-frame", condition = "changed")]
6 | | struct GpsData1(f64);
| |_____________________^
6 | | struct Data1(f64);
| |__________________^
error: expected attribute `#[simconnect(period = "...", condition = "...", interval = ...)]`. `condition` and `interval` are optional.
--> tests/02-struct-attr-errors.rs:9:1
|
9 | struct GpsData2 {}
| ^^^^^^^^^^^^^^^^^^
9 | struct Data2 {}
| ^^^^^^^^^^^^^^^
error: expected attribute `#[simconnect(period = "...", condition = "...", interval = ...)]`. `condition` and `interval` are optional.
--> tests/02-struct-attr-errors.rs:12:3

View File

@@ -3,69 +3,62 @@ use simconnect_sdk_derive::SimConnectObject;
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second", condition = "none")]
struct GpsData1 {
struct Data1 {
pub lat: f64,
}
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second", condition = "none")]
struct GpsData2 {
struct Data2 {
#[simconnect]
pub lat: f64,
}
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second", condition = "none")]
struct GpsData3 {
struct Data3 {
#[simconnect()]
pub lat: f64,
}
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second", condition = "none")]
struct GpsData4 {
#[simconnect(name = "PLANE LATITUDE")]
pub lat: f64,
}
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second", condition = "none")]
struct GpsData5 {
struct Data4 {
#[simconnect(unit = "degrees")]
pub lat: f64,
}
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second", condition = "none")]
struct GpsData6 {
struct Data5 {
#[simconnect(name = "PLANE LATITUDE", name = "PLANE LATITUDE")]
pub lat: f64,
}
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second", condition = "none")]
struct GpsData7 {
struct Data6 {
#[simconnect(unit = "degrees", unit = "degrees")]
pub lat: f64,
}
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second", condition = "none")]
struct GpsData8 {
struct Data7 {
#[simconnect(name = "PLANE LATITUDE", unit = "degrees", unit = "degrees")]
pub lat: f64,
}
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second", condition = "none")]
struct GpsData9 {
struct Data8 {
#[simconnect(nameX = "PLANE LATITUDE", unit = "degrees")]
pub lat: f64,
}
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second", condition = "none")]
struct GpsData10 {
struct Data9 {
#[simconnect(name = "PLANE LATITUDE", unitX = "degrees")]
pub lat: f64,
}

View File

@@ -1,59 +1,53 @@
error: expected attribute `#[simconnect(name = "...", unit = "...")]`
error: expected attribute `#[simconnect(name = "...", unit = "...")]`. `unit` is optional.
--> tests/03-field-attr-errors.rs:7:5
|
7 | pub lat: f64,
| ^^^^^^^^^^^^
error: expected attribute `#[simconnect(name = "...", unit = "...")]`
error: expected attribute `#[simconnect(name = "...", unit = "...")]`. `unit` is optional.
--> tests/03-field-attr-errors.rs:13:7
|
13 | #[simconnect]
| ^^^^^^^^^^
error: expected attribute `#[simconnect(name = "...", unit = "...")]`
error: expected attribute `#[simconnect(name = "...", unit = "...")]`. `unit` is optional.
--> tests/03-field-attr-errors.rs:20:7
|
20 | #[simconnect()]
| ^^^^^^^^^^^^
error: expected attribute `#[simconnect(name = "...", unit = "...")]`
error: expected attribute `#[simconnect(name = "...", unit = "...")]`. `unit` is optional.
--> tests/03-field-attr-errors.rs:27:7
|
27 | #[simconnect(name = "PLANE LATITUDE")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: expected attribute `#[simconnect(name = "...", unit = "...")]`
--> tests/03-field-attr-errors.rs:34:7
|
34 | #[simconnect(unit = "degrees")]
27 | #[simconnect(unit = "degrees")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: expected attribute `#[simconnect(name = "...", unit = "...")]`
--> tests/03-field-attr-errors.rs:41:7
error: expected attribute `#[simconnect(name = "...", unit = "...")]`. `unit` is optional.
--> tests/03-field-attr-errors.rs:34:7
|
41 | #[simconnect(name = "PLANE LATITUDE", name = "PLANE LATITUDE")]
34 | #[simconnect(name = "PLANE LATITUDE", name = "PLANE LATITUDE")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: expected attribute `#[simconnect(name = "...", unit = "...")]`
--> tests/03-field-attr-errors.rs:48:7
error: expected attribute `#[simconnect(name = "...", unit = "...")]`. `unit` is optional.
--> tests/03-field-attr-errors.rs:41:7
|
48 | #[simconnect(unit = "degrees", unit = "degrees")]
41 | #[simconnect(unit = "degrees", unit = "degrees")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: expected attribute `#[simconnect(name = "...", unit = "...")]`
--> tests/03-field-attr-errors.rs:55:7
error: expected attribute `#[simconnect(name = "...", unit = "...")]`. `unit` is optional.
--> tests/03-field-attr-errors.rs:48:7
|
55 | #[simconnect(name = "PLANE LATITUDE", unit = "degrees", unit = "degrees")]
48 | #[simconnect(name = "PLANE LATITUDE", unit = "degrees", unit = "degrees")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: expected attribute `#[simconnect(name = "...", unit = "...")]`
--> tests/03-field-attr-errors.rs:62:7
error: expected attribute `#[simconnect(name = "...", unit = "...")]`. `unit` is optional.
--> tests/03-field-attr-errors.rs:55:7
|
62 | #[simconnect(nameX = "PLANE LATITUDE", unit = "degrees")]
55 | #[simconnect(nameX = "PLANE LATITUDE", unit = "degrees")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: expected attribute `#[simconnect(name = "...", unit = "...")]`
--> tests/03-field-attr-errors.rs:69:7
error: expected attribute `#[simconnect(name = "...", unit = "...")]`. `unit` is optional.
--> tests/03-field-attr-errors.rs:62:7
|
69 | #[simconnect(name = "PLANE LATITUDE", unitX = "degrees")]
62 | #[simconnect(name = "PLANE LATITUDE", unitX = "degrees")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@@ -3,33 +3,33 @@ use simconnect_sdk_derive::SimConnectObject;
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = 123, condition = "none")]
struct GpsData1 {}
struct Data1 {}
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second", condition = 123)]
struct GpsData2 {}
struct Data2 {}
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "X")]
struct GpsData3 {}
struct Data3 {}
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second", condition = "X")]
struct GpsData4 {}
struct Data4 {}
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second", interval = "X")]
struct GpsData5 {}
struct Data5 {}
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second", interval = 0.0)]
struct GpsData6 {}
struct Data6 {}
#[derive(Debug, Clone, SimConnectObject)]
#[simconnect(period = "second", condition = "none")]
struct GpsData7 {
struct Data7 {
#[simconnect(name = "PLANE LATITUDE", unit = "degrees")]
pub lat: String,
pub lat: u64,
}
fn main() {}

View File

@@ -10,13 +10,13 @@ error: Expected Str, found Int(LitInt { token: 123 })
9 | #[simconnect(period = "second", condition = 123)]
| ^^^^^^^^^^^^^^^
error: `period` must be one of ["once", "visual-frame", "sim-frame", "second"]
error: `period` must be one of ["once", "visual-frame", "sim-frame", "second"].
--> tests/04-invalid-values.rs:13:14
|
13 | #[simconnect(period = "X")]
| ^^^^^^^^^^^^
error: `condition` must be one of ["none", "changed"]
error: `condition` must be one of ["none", "changed"].
--> tests/04-invalid-values.rs:17:33
|
17 | #[simconnect(period = "second", condition = "X")]
@@ -34,9 +34,8 @@ error: Expected Int, found Float(LitFloat { token: 0.0 })
25 | #[simconnect(period = "second", interval = 0.0)]
| ^^^^^^^^^^^^^^
error: Field type must be one of ["f64", "bool"]
--> tests/04-invalid-values.rs:31:5
error: Field type must be one of ["f64", "bool", "String"].
--> tests/04-invalid-values.rs:32:14
|
31 | / #[simconnect(name = "PLANE LATITUDE", unit = "degrees")]
32 | | pub lat: String,
| |___________________^
32 | pub lat: u64,
| ^^^