| Crates.io | cachelito-macro-utils |
| lib.rs | cachelito-macro-utils |
| version | 0.16.0 |
| created_at | 2025-11-10 15:33:05.754694+00 |
| updated_at | 2026-01-08 20:08:22.646903+00 |
| description | Shared utilities for cachelito procedural macros |
| homepage | https://github.com/josepdcs/cachelito |
| repository | https://github.com/josepdcs/cachelito |
| max_upload_size | |
| id | 1925711 |
| size | 57,716 |
Shared utilities for cachelito procedural macros.
This crate provides common parsing and code generation utilities used by both cachelito-macros (sync) and
cachelito-async-macros (async).
This crate eliminates code duplication between the sync and async macro implementations by providing shared functionality for:
limit, policy, ttl, name, scope)This crate is not meant to be used directly. It's an internal dependency of:
cachelito-macros - Procedural macros for sync functionscachelito-async-macros - Procedural macros for async functionsparse_limit_attribute() - Parse the limit attribute (returns Some(usize) or None)parse_policy_attribute() - Parse the policy attribute (returns string: "fifo" or "lru")parse_ttl_attribute() - Parse the ttl attribute (returns Some(u64) or None)parse_name_attribute() - Parse the name attribute (returns Option<String>)parse_scope_attribute() - Parse the scope attribute (returns string: "thread" or "global")generate_key_expr() - Generate cache key expression using Debug formattingSyncCacheAttributes - Struct holding parsed macro attributes with defaults for sync macrosAsyncCacheAttributes - Struct holding parsed macro attributes with defaults for async macrosuse cachelito_macro_utils::{parse_limit_attribute, parse_policy_attribute};
// In a procedural macro
for nv in parsed_args {
if nv.path.is_ident("limit") {
attrs.limit = parse_limit_attribute(&nv);
} else if nv.path.is_ident("policy") {
attrs.policy = parse_policy_attribute(&nv);
}
}
Licensed under Apache-2.0.