Hi everyone!
I have an issue similar to 39620, though I don't have any generic types, and only use two owned fields.
pub struct CloudSpeechRecognizer {
channel: Receiver<StreamingRecognizeRequest>,
key: String,
}
impl CloudSpeechRecognizer {
pub fn new(channel: Receiver<StreamingRecognizeRequest>, key: String) -> Self {
Self { channel, key }
}
pub async fn dispatch(self) -> Result<(), CloudSpeechError> {
let channel = Channel::from_static(ENDPOINT).connect().await?;
let oauth_key = MetadataValue::from_str(&self.key)?;
let mut speech = SpeechClient::with_interceptor(channel, move |mut req: Request<()>| {
req.metadata_mut()
.insert("Authorization", oauth_key.clone());
Ok(req)
});
let mut stream = speech
.streaming_recognize(self.channel.into_stream())
.await?;
let m = stream.into_inner().message().await?;
Ok(())
}
}
Caller looks like this:
let (sender, receiver) = flume::unbounded();
tokio::spawn(CloudSpeechRecognizer::new(receiver, String::from("test")));
I'm really not sure why is this happening, as into_stream
returns RecvStream<'static, _>
, thus it should be valid for 'static