You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apologies if I am missing something obvious. I am a rust newbie and and am trying to get a simple mqtt POC working.
I have this in my Cargo.toml file
[dependencies]
mqttrs = { version = "0.4", features = [ "derive" ] }
bytes = "1.0"
and this is my main file (copied verbatim from the README.md file)
use bytes::BytesMut;
use mqttrs::*;
fn main() {
// Allocate write buffer.
let mut buf = BytesMut::with_capacity(1024);
// Encode an MQTT Connect packet.
let pkt = Packet::Connect(Connect {
protocol: Protocol::MQTT311,
keep_alive: 30,
client_id: "doc_client".into(),
clean_session: true,
last_will: None,
username: None,
password: None,
});
assert!(encode(&pkt, &mut buf).is_ok());
assert_eq!(&buf[14..], "doc_client".as_bytes());
let mut encoded = buf.clone();
// Decode one packet. The buffer will advance to the next packet.
assert_eq!(Ok(Some(pkt)), decode(&mut buf));
// Example decode failures.
let mut incomplete = encoded.split_to(10);
assert_eq!(Ok(None), decode(&mut incomplete));
let mut garbage = BytesMut::from(&[0u8, 0, 0, 0] as &[u8]);
assert_eq!(Err(Error::InvalidHeader), decode(&mut garbage));
}
And the compiler complains that the encode and decode functions do not exist...
error[E0425]: cannot find function `encode` in this scope
--> src/main.rs:18:13
|
18 | assert!(encode(&pkt, &mut buf).is_ok());
| ^^^^^^ not found in this scope
error[E0425]: cannot find function `decode` in this scope
--> src/main.rs:23:31
|
23 | assert_eq!(Ok(Some(pkt)), decode(&mut buf));
| ^^^^^^ not found in this scope
|
help: consider importing this function
|
1 | use core::num::flt2dec::decode;
|
error[E0425]: cannot find function `decode` in this scope
--> src/main.rs:27:26
|
27 | assert_eq!(Ok(None), decode(&mut incomplete));
| ^^^^^^ not found in this scope
|
help: consider importing this function
|
1 | use core::num::flt2dec::decode;
|
error[E0425]: cannot find function `decode` in this scope
--> src/main.rs:29:43
|
29 | assert_eq!(Err(Error::InvalidHeader), decode(&mut garbage));
| ^^^^^^ not found in this scope
|
help: consider importing this function
|
1 | use core::num::flt2dec::decode;
|
error: aborting due to 4 previous errors
I have tried importing those functions directly in the use statement, but they do not seem to exist (compiler suggested encoder and decoder, however they were private so that provided more errors). I have also tried removing the serde feature in the Cargo.toml file to no effect.
Thanks.
The text was updated successfully, but these errors were encountered:
In addition, I'll be forking the repository to try and work in some MQTTv5 features as I have a need for some of them (mainly Message Expiry and Maximum Packet Size)
Apologies if I am missing something obvious. I am a rust newbie and and am trying to get a simple mqtt POC working.
I have this in my Cargo.toml file
and this is my main file (copied verbatim from the README.md file)
And the compiler complains that the encode and decode functions do not exist...
I have tried importing those functions directly in the use statement, but they do not seem to exist (compiler suggested encoder and decoder, however they were private so that provided more errors). I have also tried removing the serde feature in the Cargo.toml file to no effect.
Thanks.
The text was updated successfully, but these errors were encountered: