Open Altair-Bueno opened 2 months ago
I haven't looked at the async channels past 2.0. But I've started refactoring the options and data structs to be more Rust-y. Get rid of the FFI and self-referential pinning in the structs that the apps use, and convert them to FFI data in the call that sends them down to the C lib. The goal is to make the library's API fully Rust and then eventually replace the internal implementation with 100% Rust, removing the dependency on the C library. With the amount of free time I have, that may take a while, but it's the goal.
Anyway, the initial conversion of the structs may help make them easier to pass through the channels. If that's the problem here.
Well, actually the solution is far simpler:
diff --git a/examples/async_subscribe.rs b/examples/async_subscribe.rs
index a3d5050..13712bd 100644
--- a/examples/async_subscribe.rs
+++ b/examples/async_subscribe.rs
@@ -71,7 +71,7 @@ fn main() {
if let Err(err) = block_on(async {
// Get message stream before connecting.
- let mut strm = cli.get_stream(25);
+ let mut strm = std::pin::pin!(cli.get_stream(25));
// Define the set of options for the connection
let lwt = mqtt::Message::new(
diff --git a/examples/async_subscribe_v5.rs b/examples/async_subscribe_v5.rs
index 295c0eb..99e30ac 100644
--- a/examples/async_subscribe_v5.rs
+++ b/examples/async_subscribe_v5.rs
@@ -73,7 +73,7 @@ fn main() {
if let Err(err) = block_on(async {
// Get message stream before connecting.
- let mut strm = cli.get_stream(25);
+ let mut strm = std::pin::pin!(cli.get_stream(25));
// Define the set of options for the connection
let lwt = mqtt::Message::new(
AsyncChannel now is !Unpin
which forces users to pin themselves. Basically is a breaking change for consumers but the library itself is unaffected.
The motivation behind this change is to reduce compile times, dependencies and so on because async-channel gets duplicated with multiple versions when paired with crates like smol
OK. I'll have a look at that. I'll probably maintain parallel paths of the bigger (slowly evolving) changes, and keeping the mainline up to date.
Changelog: https://github.com/smol-rs/async-channel/blob/master/CHANGELOG.md#version-200
Bumping the dependency manually causes the following errors: