Usually, the state should be well-defined ahead of time, but currently apalis uses a HashMap<TypeId, State> (simplified).
https://github.com/geofmureithi/apalis/blob/28353732e45277c21966f0265464ff57b8159ec9/packages/apalis-core/src/data.rs#L10
Axum provides an option here to use the state extractor, once globally (actually per router).
https://github.com/tokio-rs/axum/blob/c4890b844b0534f5b005342ef268b9ef620c875a/axum/src/routing/mod.rs#L726-L732
So here users could have a struct instead, and this would be resolved compile-time.
Axum does have anymap but it's for extensions, and it would be rarer for such cases such that state is not known ahead of time, using https://docs.rs/http/latest/http/struct.Extensions.html.
Usually, the state should be well-defined ahead of time, but currently apalis uses a
HashMap<TypeId, State>(simplified).https://github.com/geofmureithi/apalis/blob/28353732e45277c21966f0265464ff57b8159ec9/packages/apalis-core/src/data.rs#L10
Axum provides an option here to use the state extractor, once globally (actually per router).
https://github.com/tokio-rs/axum/blob/c4890b844b0534f5b005342ef268b9ef620c875a/axum/src/routing/mod.rs#L726-L732
So here users could have a struct instead, and this would be resolved compile-time.
Axum does have anymap but it's for extensions, and it would be rarer for such cases such that state is not known ahead of time, using https://docs.rs/http/latest/http/struct.Extensions.html.