Hi
How do I modify the following function because I am getting some mismatched type errors.
fn on_connect() -> (&'static str, &'static str, &'static str, &'static str, &'static str) {
let m = Mosquitto::new("slm");
let conf = Ini::load_from_file("conf.ini").unwrap();
let mqtt = conf.section(Some("Mqtt")).unwrap();
let broker = mqtt.get("broker_ip").unwrap();
let connect = m.connect(broker, 1883).expect("Failed to connect to broker");
(m, conf, mqtt, broker, connect)
}
pi@raspberrypi:~/rust/slm_controller $ cargo run
Compiling slm_controller v0.1.0 (/home/pi/rust/slm_controller)
warning: unused import: `serde_json::json`
--> src/main.rs:5:5
|
5 | use serde_json::json;
| ^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: unused import: `std::collections::HashMap`
--> src/main.rs:6:5
|
6 | use std::collections::HashMap;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> src/main.rs:16:6
|
16 | (m, conf, mqtt, broker, connect)
| ^ expected `&str`, found struct `mosq::Mosquitto`
error[E0308]: mismatched types
--> src/main.rs:16:9
|
16 | (m, conf, mqtt, broker, connect)
| ^^^^ expected `&str`, found struct `ini::Ini`
error[E0308]: mismatched types
--> src/main.rs:16:15
|
16 | (m, conf, mqtt, broker, connect)
| ^^^^ expected `str`, found struct `ini::ini::Properties`
|
= note: expected reference `&'static str`
found reference `&ini::ini::Properties`
error[E0308]: mismatched types
--> src/main.rs:16:29
|
16 | (m, conf, mqtt, broker, connect)
| ^^^^^^^ expected `&str`, found `()`
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0308`.
error: could not compile `slm_controller`.
The link for the mosquitto client library is as follows because I am using the mosquitto client as the mqtt: GitHub - stevedonovan/mosquitto-client
Thanks