How to read the error messages like below?

I'm new to Rust, I'm playing a grpc server implementation build on top of tower/hyper/tonic.
Some code fail to compile and give below errors:

mismatched types [E0308] expected Either<MapErr<MapOk<FilteredFuture<Pin<Box<dyn Future<Output=core::result::Result<(impl Reply,), Rejection>>+Send>>>, fn(Response) -> Response<EitherBody<<unknown>, <unknown>>>>, fn(<unknown>) -> Box<dyn Error+Send+Sync>>, <unknown>>, found `()

How to read this kind of error messages and figure out why it expects such a long complex type?

It's really hard to help without more context. Since the found type is the unit type (), you might be chaining methods and eventually call a method that doesn't return anything. You'll likely have to break the chain and do something like:

let mut my_value = this.calls().some().functions();
my_value.mutate(); // `mutate()` returns `()`
my_value.continyou().chaining().methods();

The section Debugging handler type errors in the documentation for axum::handler may be relevant.

The mistake I made was having something that was not Send. The error message suggests to me that could be your problem. Although... I think your error is something a little different. Still some kind of trait bound problem though.

I think code is needed to diagnose what is wrong!

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.