| Crates.io | csv-codegen |
| lib.rs | csv-codegen |
| version | 0.2.3 |
| created_at | 2025-06-20 05:34:48.305229+00 |
| updated_at | 2025-10-24 12:52:04.996597+00 |
| description | A Rust procedural macro that transforms CSV data into safe, zero-cost code. Generate match arms, loops, and nested queries directly from CSV files, ensuring type safety and deterministic code generation. |
| homepage | https://git.sr.ht/~platy/csv-codegen |
| repository | https://git.sr.ht/~platy/csv-codegen |
| max_upload_size | |
| id | 1719144 |
| size | 167,110 |
A Rust procedural macro for generating code from CSV data at compile time. Transform CSV files into Rust constants, functions, structs, and other code using a flexible templating syntax.
Status: This crate is in development and was built with AI assistance (Claude Code). The API may see changes in future versions. Contributions and code review are especially welcome!
42_f64, 10_u32, etc.)Add this to your Cargo.toml:
[dependencies]
csv-codegen = "0.2"
Given a CSV file products.csv:
name,price,category
apple,1.20,fruit
carrot,0.80,vegetable
banana,0.90,fruit
Generate constants:
use csv_codegen::csv_template;
csv_template!("products.csv", #each {
pub const #CONST({name}_PRICE): f64 = #({price}_f64);
});
// Generates:
// pub const APPLE_PRICE: f64 = 1.20_f64;
// pub const CARROT_PRICE: f64 = 0.80_f64;
// pub const BANANA_PRICE: f64 = 0.90_f64;
assert_eq!(APPLE_PRICE, 1.20);
For more examples including filtering, pivoting, and advanced templating, see the full documentation.
==, !=, &&, ||) and only comparing between fields and literalsFor additional real-world examples including internationalization, enum generation, medical data processing, and complex nested filtering, see the integration test suite.
Licensed under Apache License, Version 2.0 (see LICENSE file or https://www.apache.org/licenses/LICENSE-2.0)