Relative Content

Tag Archive for rustrust-axum

Rust Axum, binary type returned in handler fn

I have Axum handler which returns Vec<u8>, binary data. The result is often the same so I cache it using dashmap. The issue is dashmap get gives me refrence, so to return it from Axum handler I need to always clone it first to have owned version bytes.clone(). Is it possible to not do it every time? Since I am only reading this data, why Axum needs owned version of it? Is it somehow moved into network socket or something like that? Also is unsafe rust something to get around that ? Or maybe I need to get around it with implementing my own IntoResponse.

Is it ok to clone a connection pool in rust/axum?

I’m new to rust & axum and trying to wrap my head around setting up a scalable and clean architecture. When running locally, I sometimes notice a lag before the reponse comes in. This could have many reasons, but one thing I’m investigating is how I’m sharing my connection pool.