Skip to content

Commit 4b8aee3

Browse files
committed
add parser prototype for IoText message in RUST
1 parent ed665f2 commit 4b8aee3

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/test_parse.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl ItemType {
3131
enum MetricValueType {
3232
IntegerItemType(i64),
3333
BoolItemType(bool),
34-
//DecimalItemType(i64),
34+
//DecimalItemType(Decimal),
3535
TextItemType(String),
3636
}
3737

@@ -41,7 +41,7 @@ enum ItemTypeEnum {
4141
DeviceId(String),
4242
}
4343

44-
const MSG_EXAMPLE: &str = "t|3900237526042,d|device_name_001,m|val_water_level1=i:42,m|light_on=b:1,m|bulb_on=b:0,m|msg_machine_01=t:hello";
44+
const MSG_EXAMPLE: &str = "t|3900237526042,d|device_name_001,m|val_water_level1=i:42,m|light_on=b:1,m|bulb_on=b:0,m|msg_machine_01=t:hello,m|wind_speed=d:1234.5678";
4545

4646
fn main() {
4747
let item_parts: Vec<&str> = MSG_EXAMPLE
@@ -90,6 +90,14 @@ fn main() {
9090
MetricValueType::TextItemType(metric_parts_values[1].to_string())
9191
)
9292
}
93+
/*
94+
MetricDataTypes::DECIMAL => {
95+
println!(
96+
"\t\t\tDecimalItemType: {:?}",
97+
MetricValueType::DecimalItemType(metric_parts_values[1].to_string())
98+
)
99+
}
100+
*/
93101
_ => println!("\t\t\tother"),
94102
}
95103
} else {
@@ -166,4 +174,10 @@ item_part: ["m", "msg_machine_01=t:hello"]
166174
metric_parts: ["msg_machine_01", "t:hello"]
167175
metric_parts_values: ["t", "hello"]
168176
BoolItemType: TextItemType("hello")
177+
part: m|wind_speed=d:1234.5678
178+
item_part: ["m", "wind_speed=d:1234.5678"]
179+
metric: wind_speed=d:1234.5678
180+
metric_parts: ["wind_speed", "d:1234.5678"]
181+
metric_parts_values: ["d", "1234.5678"]
182+
other
169183
*/

0 commit comments

Comments
 (0)