Skip to content

Return state data without cloning 🤔 #2832

Answered by jplatte
NiiightmareXD asked this question in Q&A
Discussion options

You must be logged in to vote

You can actually do Json<Arc<_>> if you enable serde's rc feature: https://docs.rs/serde/latest/serde/trait.Serialize.html#impl-Serialize-for-Arc%3CT%3E

Alternatively, you can use axum-extra's ErasedJson type and pass a reference to the arc-wrapped value to its constructor.

Finally, we could probably make axum support Arc<Json<_>> as a response type, but I'm not sure how useful that would be here.

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@NiiightmareXD
Comment options

@jplatte
Comment options

@NiiightmareXD
Comment options

@jplatte
Comment options

Answer selected by NiiightmareXD
@NiiightmareXD
Comment options

@jplatte
Comment options

@NiiightmareXD
Comment options

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