Crate hitbox_derive[−][src]
Expand description
This crate provides default implementations for Cacheable and CacheableResponse derive macros.
You can see an example of Cacheable derive macro below:
ⓘ
use hitbox::cache::Cacheable; use hitbox::error::CacheError; use serde::Serialize; #[derive(Cacheable, Serialize)] #[cache_ttl(120)] #[cache_stale_ttl(100)] #[cache_version(100)] struct Message { field: i32, }; let message = Message { field: 42 }; assert_eq!(message.cache_message_key().unwrap(), "Message::v100::field=42".to_string());
CacheableResponse example:
ⓘ
use hitbox::response::CacheableResponse; use serde::Serialize; #[derive(CacheableResponse, Serialize)] pub enum MyResult { OptionOne(i32), OptionTwo(String), }
Derive Macros
Cacheable | Derive Cacheable macro implementation. |
CacheableResponse | Derive CacheableResponse macro implementation. |