Why is compiler complaining about 'static if I pass only owned values

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<()>| {
                .insert("Authorization", oauth_key.clone());


        let mut stream = speech

        let m = stream.into_inner().message().await?;


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

I kinda fixed it by passing R: Stream<Item = StreamingRecognizeRequest> + 'static + Send + Sync instead of Receiver, though I still don't know the cause of problem

Please include the use statements so I know which Receiver it is.

Oh, sorry.
Here's a bit more detailed info:
Receiver - flume::Receiver - Rust
streaming_recognize (auto-generated):

        pub async fn streaming_recognize(
            &mut self,
            request: impl tonic::IntoStreamingRequest<Message = super::StreamingRecognizeRequest>,
        ) -> Result<
        > {
            self.inner.ready().await.map_err(|e| {
                    format!("Service was not ready: {}", e.into()),
            let codec = tonic::codec::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                .streaming(request.into_streaming_request(), path, codec)

Though the most interesting part of this function is IntoStreamingRequest

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.