RusotoFuture does not implement Future

I'm attempting to list the objects of an S3 bucket using rusoto_s3 and have run against an error I think I understand, but would like validation on.

Below are the vitals:

  • Rust version: rustc 1.58.1 (db9d1b20b 2022-01-20)
  • rusoto_s3 = "0.42.0"
  • tokio = { version = "1", features = ["rt-multi-thread", "macros"] }

Minimal Example:

#[tokio::main]
async fn main() {
    let args = Opts::from_args();

    let client = S3Client::new(Region::UsEast1);
    let resp = client.list_objects_v2(ListObjectsV2Request {
		bucket: args.location.bucket,
		prefix: args.location.path,
        ..Default::default()
    }).await;
}

Attempting to compile the above snippet results in the following error:

error[E0277]: `rusoto_core::future::RusotoFuture<ListObjectsV2Output, ListObjectsV2Error>` is not a future
  --> src/bin/list_objects/main.rs:47:16
   |
47 |       let resp = client.list_objects_v2(ListObjectsV2Request {
   |  ________________^
48 | |         bucket: args.location.bucket,
49 | |         prefix: args.location.path,
50 | |         ..Default::default()
51 | |     }).await;
   | |____________^ `rusoto_core::future::RusotoFuture<ListObjectsV2Output, ListObjectsV2Error>` is not a future
   |
   = help: the trait `Future` is not implemented for `rusoto_core::future::RusotoFuture<ListObjectsV2Output, ListObjectsV2Error>`

My assumption is that there's a mismatch between Future here. RusotoFuture implements futures::Future but I'm guessing the Future referenced in the error message is actually std::futures::Future. Does this seem plausible?

I feel like this worked as is at some point in the past ( I don't have evidence to back that up, so it's entirely possible I'm misremembering). I noticed rusoto is in maintenance mode; is it possible this is drift between rust version and a potentially aging crate? Am I just doing it wrong?

Whatever the case, this issue has afforded an interesting challenge: How could I implement std::future::Future for RusotoFuture given that the struct is not in my crate, and the trait is in the std library? Define some form of adapter struct/enum in my own create and implement std::future::Future for that construct? I'd love to hear some thoughts.

It seems you're using an old version of rusoto that predates the addition of Future to the standard library. rusoto_core 0.43.0 and later use std::future::Future, so upgrading rusoto_s3 to a recent release—if one exists—should fix this problem.

3 Likes

It sure does! I don't know why I thought I was on the latest version of rusoto. Long day I guess.

For a more hypothetical question, how would one solve this issue there wasn't a version of rusoto that used std::future::Future ? I assume I'd need to have my own wrapper type that implements future to get around the orphan rule. Are there any other patterns that would mitigate this theoretical issue?

There generally isn't a good way to do it if the crate is that old.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.