Skip to content

Instantly share code, notes, and snippets.

@mfenniak
Created February 21, 2021 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfenniak/432eb3f6ea71ae9b2836c98e5be60cba to your computer and use it in GitHub Desktop.
Save mfenniak/432eb3f6ea71ae9b2836c98e5be60cba to your computer and use it in GitHub Desktop.
Not sure how to resolve this Rust compilation issue
pub struct SqsSink {
// ...snip...
sqs_client: SqsClient,
send_message_future: Option<std::pin::Pin<std::boxed::Box<dyn futures::Future<Output = std::result::Result<rusoto_sqs::SendMessageBatchResult, rusoto_core::RusotoError<rusoto_sqs::SendMessageBatchError>>> + std::marker::Send>>>,
}
impl Sink<Arc<Box<dyn MessageChunk>>> for SqsSink {
type Error = ();
// ...snip...
fn poll_flush(mut self: std::pin::Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
// ...snip...
let fut = self.sqs_client.send_message_batch(send_message_batch_request);
self.send_message_future = Some(fut);
// ...snip...
}
// ...snip...
}
/*
Causes compile error:
error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
--> src/sqs_sink.rs:80:31
|
45 | fn poll_flush(mut self: std::pin::Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
| ------------------------ this data with an anonymous lifetime `'_`...
...
80 | let fut = self.sqs_client.send_message_batch(send_message_batch_request);
| ^^^^^^^^^^^^^^^ ...is captured here...
81 | self.send_message_future = Some(fut);
| --------- ...and is required to live as long as `'static` here
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment