pub async fn send_and_expect(&mut self, request: rtsp_types::Request<Body>, retrying: bool) -> std::result::Result<rtsp_types::Response<Body>, ClientActionError> {
I get:
recursion in an `async fn` requires boxing recursive `async fn` note: a recursive `async fn` must be rewritten to return a boxed `dyn Future`rustc(E0733)
I found https://rust-lang.github.io/async-book/07_workarounds/04_recursion.html but it is for a function that does not use async
.
What should be the way here?
I found Why recursive async functions require 'static parameters in Rust? and I changed my function to
pub fn send_and_expect(&mut self, request: rtsp_types::Request<Body>, retrying: bool) -> Pin<Box<dyn Future <Output = std::result::Result<rtsp_types::Response<Body>, ClientActionError>>>> {
but now I cannot use await
inside my funtion. Also, how do I return things?
For example:
return Box::pin(Err(ClientActionError::CSeqMissing))
won't work
https://stackoverflow.com/questions/67030184/can-i-use-await-inside-async-recursive-functions April 10, 2021 at 10:07AM
没有评论:
发表评论