Is your feature request related to a problem? Please describe.
Basically when looking at warp initially, one thing which isn't entirely clear is how to attach application state to filters.
any has examples if / when one stumbles on it, but it feels like for the common cases there could be simple filters available out of the box for the most common cases, either in the any module or in a data or state module.
Describe the solution you'd like
I think useful data / state filters would be:
copied data filter which would own and provide a Copy resource.
cloned data filter which would own and provide Clone resource
then a set of more state-oriented filters which would manage the reference-counting and locking e.g. an exclusive filter which would internally be a Arc<Mutex<T>> but would provide a MutexGuard<T>, and something like a filter builder which would internally be a Arc<RwLock<T>> with a reading and a writing methods, which would respectively provide an RwLockReadGuard and an RwLockWriteGuard.
If these were built on top of any I guess they could also make the typing clearer, or maybe that should be documented separately? e.g. how to type helper functions when extracting routes into submodules or creating utility filters.
Describe alternatives you've considered
Providing more of a "how to", or maybe a small list of common warp patterns, at the root of the documentation (either after Filters or as a sub-section).
Is your feature request related to a problem? Please describe. Basically when looking at warp initially, one thing which isn't entirely clear is how to attach application state to filters.
any
has examples if / when one stumbles on it, but it feels like for the common cases there could be simple filters available out of the box for the most common cases, either in theany
module or in adata
orstate
module.Describe the solution you'd like I think useful data / state filters would be:
copied
data filter which would own and provide aCopy
resource.cloned
data filter which would own and provideClone
resourceexclusive
filter which would internally be aArc<Mutex<T>>
but would provide aMutexGuard<T>
, and something like a filter builder which would internally be aArc<RwLock<T>>
with areading
and awriting
methods, which would respectively provide anRwLockReadGuard
and anRwLockWriteGuard
.If these were built on top of
any
I guess they could also make the typing clearer, or maybe that should be documented separately? e.g. how to type helper functions when extracting routes into submodules or creating utility filters.Describe alternatives you've considered Providing more of a "how to", or maybe a small list of common warp patterns, at the root of the documentation (either after Filters or as a sub-section).