3 ms·
While extractors are sometimes doing copies, it is basically never in situations where it matters. For example extractors on the json body will always _move th
by dathinab 4y ago
While extractors are sometimes doing copies, it is basically never in situations where it matters.
For example extractors on the json body will always _move the body out of the request_ (independent of the position the extractor is in).
Sure there is some copying for e.g. request parameters, but you very often do that anyway as you e.g. do some urldecoding, parsing and similar on the parameters, e.g. extracting a Uuid type from a `/user/9313ba53-955e-4ce1-8b53-de8f92656196/bar` path.
Similar if the extractor doesn't return the error type you want you can wrap it an map the error when extracting. Sure with actix-web and warp there are some error handling situations which they don't handle well, but that got improved on in axume.
Application state is shared across threads (or at least across time) so it's anyway in a `Arc` or `Rc` so you are just cloning the reference pointer but not the data behind it.
Lastly if you have a very special situation you can decide to just accept a `Request` moving (not copying) it into the handle and do the rest yourself by hand.
Without question the system has potential for improvements, but for now it has become the de-facto standard due to it being very convenient, does work well for many use cases and does not add a relevant performance overhead for a lot of use cases.
Now their solution is targeting backend WASM so they probably use will focus in single threaded WASM with some snapshot mechanics to easily sandbox each request so their requirements are anyway a bit different but looking into history routing macros where common in the past as far as I remember, and they are pretty much all gone by now.
But then they probably will go through a bunch of revisions of their system, so it's not like they can't add it back in later one.
EDIT: Just to be clear their solution is a fully valid reasonable approach.