| Crates.io | batch-mode-token-expansion-axis-derive |
| lib.rs | batch-mode-token-expansion-axis-derive |
| version | 0.1.3 |
| created_at | 2025-03-31 22:09:33.406424+00 |
| updated_at | 2025-07-13 11:31:44.456293+00 |
| description | A procedural macro crate for deriving token expansion axes. |
| homepage | |
| repository | https://github.com/klebs6/klebs-general |
| max_upload_size | |
| id | 1614131 |
| size | 159,775 |
This crate provides a procedural macro #[derive(TokenExpansionAxis)] for enumerations, enabling automatic implementation of axis-related traits from the batch-mode-token-expansion-axis crate. By specifying attributes like #[system_message_goal("...")] and #[axis("axis_name => axis_description")], you can generate:
Expanded...).TokenExpander and SystemMessageGoal, tying the process together.#[system_message_goal("Convert tokens to JSON")]).#[axis("my_axis => Provides an axis for expansion")]).Default, Named, TokenExpander, and SystemMessageGoal, facilitating batch expansions.Expanded...) that includes fields derived from your enumeration variants.use batch_mode_token_expansion_axis_derive::TokenExpansionAxis;
use std::borrow::Cow;
#[derive(TokenExpansionAxis, Debug)]
#[system_message_goal("Transform tokens along multiple axes")]
enum ExampleExpanderAxis {
#[axis("lang => Expands the language dimension")]
Language,
#[axis("style => Expands the style dimension")]
Style,
}
When this derives, it generates:
AxisName, AxisDescription, and TokenExpansionAxis on ExampleExpanderAxis.ExpandedExampleExpander (if you strip off the ExpanderAxis suffix, it becomes ExpandedExample—the macro handles naming automatically).ExampleExpander, which implements traits like TokenExpander and SystemMessageGoal.Add to Cargo.toml:
[dependencies]
batch-mode-token-expansion-axis = "0.1"
batch-mode-token-expansion-axis-derive = "0.1"
Import and Use:
use batch_mode_token_expansion_axis_derive::TokenExpansionAxis;
use batch_mode_token_expansion_axis::{TokenExpansionAxis, AxisName, AxisDescription};
#[derive(TokenExpansionAxis)]
enum MyAxis {
#[axis("color => Expand color variations")]
Color,
#[axis("size => Expand size variations")]
Size,
}
Leverage the Generated Code:
MyExpander) allows accessing all enum variants as Arc<dyn TokenExpansionAxis>.ExpandedMy) supports serialization, deserialization, and other derived functionality.This library is designed to integrate seamlessly with batch-mode-token-expansion-axis, providing a clean, DRY approach to multi-dimensional token expansions.