Migrating future stream

Hi, I am using a library that is still on futures 0.1 while I'm depending on 0.3 in my project. I am trying to get the following code to compile but it doesn't since mpsc::Receiver has moved from futures::sync::mpsc::Receiver to futures::channel::mpsc::Receiver:

use futures::{
    compat::{Future01CompatExt, Stream01CompatExt},
let receiver: Compat01As03<futures::channel::mpsc::Receiver<Option<paho_mqtt::message::Message>>> = client.get_stream(10).compat();

But of course this doesn't compile because the Receiver is located in another module as noted above.
Is there support for this migration in the compat layer or is there a way to omit the type (of course in this example it is possible but I mean if I were to send it into another function)?

Can't you just, you know, specify the correct path?

Not sure if you're referring to the module I'm using Receiver from? It has moved from futures::sync::mpsc in futures version 0.1 to futures::channel::mpsc in version 0.3.

I don't understand the problem. Can't you just use the correct one of them depending on which version's channel you want?

Maybe I'm wording this badly or I am missing something here.
For the project I am working on I want to use futures 0.3 to get async/await support. The project I am depending on, however, is using futures 0.1. I've tried to solve this problem by using futures::compat that wraps futures 0.1 in futures 0.3 terms. However I get stuck here where it manages to get the outer type correct Compat01As03 by the use of the compat function but the inner type still has the Receiver from futures::sync::mpsc while I can only access futures::channel::mpsc since I am using a newer version.
If I were to correct one of them, how would that look code-wise? Do I write a new wrapper around the Receiver?

You can depend on both versions of futures simultaneously by renaming one of the dependencies.

futures = "0.3"
futures01 = { version = "0.1", package = "futures" }

I hadn't even thought about that possibility. Tried it out and it works. Thanks a lot!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.