cachelito-macro-utils
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).
Purpose
This crate eliminates code duplication between the sync and async macro implementations by providing shared functionality for:
- Parsing macro attributes (
limit,policy,ttl,name,scope) - Generating cache key expressions
- Common data structures
Usage
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 functions
Public API
Parsing Functions
parse_limit_attribute()- Parse thelimitattribute (returnsSome(usize)orNone)parse_policy_attribute()- Parse thepolicyattribute (returns string:"fifo"or"lru")parse_ttl_attribute()- Parse thettlattribute (returnsSome(u64)orNone)parse_name_attribute()- Parse thenameattribute (returnsOption<String>)parse_scope_attribute()- Parse thescopeattribute (returns string:"thread"or"global")
Code Generation
generate_key_expr()- Generate cache key expression usingDebugformatting
Data Structures
SyncCacheAttributes- Struct holding parsed macro attributes with defaults for sync macrosAsyncCacheAttributes- Struct holding parsed macro attributes with defaults for async macros
Example
use ;
// In a procedural macro
for nv in parsed_args
License
Licensed under Apache-2.0.