Skip to content

Conversation

@andogq
Copy link
Owner

@andogq andogq commented Jul 27, 2025

Complete overhaul of the router, and the handler macro. Instead of the handler macro replacing the function definition with a custom struct which implements a trait in order to 'smuggle' reflection information (function and parameter names) to the runtime, this implementation leaves the function definition as-is and uses linkme to save the information during the linking step. This provides a number of advantages:

  • Less codegen in the macro, so faster and less fragile
  • Handlers can now be called from within Rust code as standard methods (eg for unit testing)
  • No more weird type-erasure hacks

Another significant change is that the macro no longer tries to statically analyse the handler signature (such as checking if the return type is impl ____ to guess if it's a stream). Now, the trait system is used to correctly infer the return type every time! Along with being more predictable, this allows for other non-stream traits to be returned from handlers, such as impl Iterator!

andogq added 30 commits July 4, 2025 23:41
potentially the most heinous thing I have ever written
includes pretty major change to `QubitHandler` to differentiate router
`Ctx` from handler `Ctx`.
@andogq andogq merged commit f6b3535 into main Jul 27, 2025
18 checks passed
@andogq andogq deleted the feat/router-rewrite branch July 27, 2025 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant