1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! This crate provides default implementations for Cacheable and CacheableResponse derive macros.
//!
//! You can see an example of Cacheable derive macro below:
//! ```edition2018,ignore
//! 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:
//! ```edition2018,ignore
//! use hitbox::response::CacheableResponse;
//! use serde::Serialize;
//!
//! #[derive(CacheableResponse, Serialize)]
//! pub enum MyResult {
//! OptionOne(i32),
//! OptionTwo(String),
//! }
//! ```
use TokenStream;
/// Derive Cacheable macro implementation.
/// Derive CacheableResponse macro implementation.