You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Platform
Linux sufjan 5.15.0-46-generic #49~20.04.1-Ubuntu SMP Thu Aug 4 19:15:44 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Description
Thanks to the wrap_fn function, warp users are able to create their own Wraps for use with .with(). Super cool! However, in order to have a nice reusable Wrap, I would like to have a function that returns a Wrap. We can do something similar with filters by making a function that returns impl Filter<...>. However, this doesn't work with Wrap because Wrap, WrapSealed, and the concrete type WrapFn are all private, so afaict there's no way for me to define a function that returns the result of wrap_fn.
This shouldn't be a macro, but I couldn't make it a function, so this was the next best way to make my wrapper reusable. I also noticed that the Wrap trait is marked as pub, but it's in the private module warp::filter::wrap and isn't re-exported anywhere, so it's inaccessible to the user. Did you mean to re-export Wrap so that it can be used like Filter?
The text was updated successfully, but these errors were encountered:
Today I tried to do something similar as well. I was attempting to make my own CORS wrapper using WrapFn as the built-in one didn't fit my needs very well. I ended up just passing in a function and handling it differently.
Version
0.3.2
Platform
Linux sufjan 5.15.0-46-generic #49~20.04.1-Ubuntu SMP Thu Aug 4 19:15:44 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Description
Thanks to the
wrap_fn
function, warp users are able to create their ownWrap
s for use with.with()
. Super cool! However, in order to have a nice reusableWrap
, I would like to have a function that returns aWrap
. We can do something similar with filters by making a function that returnsimpl Filter<...>
. However, this doesn't work withWrap
becauseWrap
,WrapSealed
, and the concrete typeWrapFn
are all private, so afaict there's no way for me to define a function that returns the result ofwrap_fn
.Here's the (pseudo)code that I want to write:
I would also be happy to put the concrete type
WrapFn<???>
as the return type instead. However, instead I had to write the following code:This shouldn't be a macro, but I couldn't make it a function, so this was the next best way to make my wrapper reusable. I also noticed that the
Wrap
trait is marked aspub
, but it's in the private modulewarp::filter::wrap
and isn't re-exported anywhere, so it's inaccessible to the user. Did you mean to re-exportWrap
so that it can be used likeFilter
?The text was updated successfully, but these errors were encountered: