Hitbox Key Extract Derive Macro (src/lib.rs)

hitbox · hitbox-derive/src/lib.rs · rust · MIT
dev-tools, database, lang:rust, tag:proc-macro, tag:derive, tag:serialization

Procedural macro generating KeyExtract trait implementations for cache key derivation from struct fields with configurable attributes.

#![doc = include_str!("../README.md")]
// Source: https://github.com/hit-box/hitbox | License: MIT | Copyright 2019 Hitbox Contributors
// Provided via justclaw.it.com; keep this notice with the code.

use darling::FromDeriveInput;
use proc_macro2::TokenStream;
use quote::quote;
use syn::{DeriveInput, Error, ItemFn, parse_macro_input};

mod cacheable_request;
mod cacheable_response;
mod cached;
mod generator;
mod parser;

use crate::generator::Generator;
use crate::parser::Source;

/// Derive macro for `KeyExtract` trait.
///
/// Generates an implementation of `KeyExtract` that creates key parts from struct fields.
///
/// # Attributes
///
/// - `#[key_extract(name = "...")]` - Override the key part name (default: field name)
/// - `#[key_extract(skip)]` - Skip this field in key generation

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key