| Crates.io | csv-codegen |
| lib.rs | csv-codegen |
| version | 0.2.2 |
| created_at | 2025-06-20 05:34:48.305229+00 |
| updated_at | 2025-08-05 20:13:14.091684+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 | |
| repository | |
| max_upload_size | |
| id | 1719144 |
| size | 116,627 |
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.
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 literalsLicensed under Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)