Skip to content

Trouble migrating from v0.3.x to v0.5.x using Tokio spawn #103

@petewasher-flybrid

Description

@petewasher-flybrid

Hello,
Previously I was using a v0.3 which worked great for my system. I am now trying to migrate to v0.5.

I have two main parts of the application:

  1. Collects information from a system and provides this as a queue of incoming messages
  2. Maintains MQTT connection and delivers these messages to MQTT as they appear from the queue.

This works from two Tokio tasks. I have gone through and migrated from v0.3 syntax to v0.5 syntax, this appears to work fine and the MQTT delivery module I have compiles fine.

When I try and use this from the main application, I have problems with this function from main:

tokio::spawn(async move {
            mqtt_delivery::mqtt_pump(mqtt_socket.clone(), mqtt_provider).await;
        });

Which are various types of:

error: implementation of `Send` is not general enough
   --> src/main.rs:222:9
    |
222 | /         tokio::spawn(async move {
223 | |             mqtt_delivery::mqtt_pump(mqtt_socket.clone(), mqtt_provider).await;
224 | |         });
    | |__________^ implementation of `Send` is not general enough
    |
    = note: `Send` would have to be implemented for the type `&rust_mqtt::client::options::publish::Options<'_>`
    = note: ...but `Send` is actually implemented for the type `&'0 rust_mqtt::client::options::publish::Options<'_>`, for some specific lifetime `'0`

Is there some way I can work through this? It doesn't seem that clear how I can provide either the correct Send or the right lifetime.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions