Skip to content
Discussion options

You must be logged in to vote

The state must be Clone, axum doesn't really care if it's Arc, AppState where you manually implement Clone or even i32.

It's important to realize that each handler will get a new clone of the state. So if you use a custom struct where you make deep copies, the handlers can't update the data for later handler calls. That (along with cloning Arcs being generally cheap) is why in most use cases you would use an Arc for state.

Does that clear things up for you? Do you have any suggestions on how to improve the documentation?

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ColemanDunn
Comment options

Answer selected by ColemanDunn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants