error[E0277]: the size for values of type `(dyn core::future::future::Future<Output = std::result::Result<(), anyhow::Error>> + 'static)` cannot be known at compilation time
--> src/bin/sxsim/control/process/appmngr.rs:144:9
|
144 | futures::Future<Output=anyhow::Result<()>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
::: /home/hjansen/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/ops/function.rs:228:5
|
228 | type Output;
| ------------ required by this bound in `std::ops::FnOnce`
|
= help: the trait `std::marker::Sized` is not implemented for `(dyn core::future::future::Future<Output = std::result::Result<(), anyhow::Error>> + 'static)`
Since anyhow is widely used I would believe there is an idiomatic way to resolve this... Help/guidance appreciated! Thanks.
I think you're missing one level of indirection. The function returns some type which implements future::Future, not the trait itself. You can fix that with this:
However, that'll bring you to another set of errors relating to how serve takes in generic parameters, and you've declared them again as concrete traits. I don't know if there's as easy of a fix here - Fn closures can't be generic over types.
Maybe you could change serve to take in Box<dyn tokio::io::AsyncRead + Unpin + Send> and the same for AsyncWrite, rather than a generic? Then it itself wouldn't be generic, and you could pass it as an Fn(Box<dyn ...>, Box<dyn ...>) -> T.