Skip to content

Cannot construct router in trait #2906

Answered by jplatte
appetrosyan asked this question in Q&A
Discussion options

You must be logged in to vote

Hi!

I think the problem is likely with trait implementations being allowed to override async fn telemetry_handler with an async fn whose Future type does not implement Send. That error about Self is unrelated, it's just a consequence of how debug_handler works internally - unfortunately you can't use it in a trait impl where the async fn calls an associated function of the same trait (I think).

The fix here should be to change the definition of telemetry_handler to

    fn telemetry_handler(
    ) -> impl std::future::Future<Output = axum::response::Response> + Send {
        async {
            use axum::response::IntoResponse as _;

            let mut buffer = String::new();

            

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@jplatte
Comment options

@appetrosyan
Comment options

@appetrosyan
Comment options

@jplatte
Comment options

Answer selected by appetrosyan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants