#[derive(CacheableResponse)]
{
// Attributes available to this derive:
#[cacheable_response]
}
Expand description
Derive macro for CacheableResponse trait.
Generates an implementation of CacheableResponse where the type is cached as itself.
The type must implement Clone + Serialize + DeserializeOwned + Send + 'static.
§Example
ⓘ
use hitbox_derive::CacheableResponse;
use serde::{Deserialize, Serialize};
#[derive(Clone, Serialize, Deserialize, CacheableResponse)]
struct User {
id: u64,
name: String,
}
// Now User can be used as a return type in cached functions:
#[cached]
async fn fetch_user(id: u64) -> Result<User, Error> {
// ...
}