Crates.io | structs-from-excel |
lib.rs | structs-from-excel |
version | 0.2.2 |
source | src |
created_at | 2023-03-10 03:11:22.382898 |
updated_at | 2023-03-10 03:30:48.586037 |
description | crate that adds a procedural macro that unravels structs via a given, purpose-formatted Excel spreadsheet |
homepage | |
repository | https://github.com/IoIxD/structs-from-excel |
max_upload_size | |
id | 806049 |
size | 16,650 |
This crate adds a procedural macro that will generate structs based on a given Excel spreadsheet. It was made for a project where I knew that one of the people helping was not going to want to work with JSON or XML or anything reasonable. I'm sorry.
Invocation of the macro is as follows:
use structs_from_excel;
#[sheet("resources/objects.xls")]
pub struct Object; // This struct will get ignored and replaced by whatever structs you define. Anything can go here, pretty much.
Each sheet is then read and parsed, keeping the following rules in mind:
The following two sheets:
become:
enum StructsFromExcel {
Slime(Slime),
OtherSlime(OtherSlime),
PlayerOne(PlayerOne),
PlayerTwo(PlayerTwo),
PlayerThree(PlayerThree),
PlayerFour(PlayerFour),
}
pub struct Slime {
pub hp: i32,
}
impl Default for Slime {
fn default() -> Self {
Self { hp: 30 }
}
}
impl Slime {
pub fn new() -> Self {
return Default::default();
}
}
pub struct OtherSlime {
pub hp: i32,
}
impl Default for OtherSlime {
fn default() -> Self {
Self { hp: 60 }
}
}
impl OtherSlime {
pub fn new() -> Self {
return Default::default();
}
}
pub struct PlayerOne {
pub what: f32,
pub wa: String,
pub hp: i32,
}
impl Default for PlayerOne {
fn default() -> Self {
Self {
what: 15.5,
wa: String::from("lorem"),
hp: 20,
}
}
}
impl PlayerOne {
pub fn new() -> Self {
return Default::default();
}
}
pub struct PlayerTwo {
pub hp: i32,
pub wa: String,
pub what: f32,
}
impl Default for PlayerTwo {
fn default() -> Self {
Self {
hp: 20,
wa: String::from("ipsum"),
what: 15.5,
}
}
}
impl PlayerTwo {
pub fn new() -> Self {
return Default::default();
}
}
pub struct PlayerThree {
pub what: f32,
pub wa: String,
pub hp: i32,
}
impl Default for PlayerThree {
fn default() -> Self {
Self {
what: 15.5,
wa: String::from("dot"),
hp: 20,
}
}
}
impl PlayerThree {
pub fn new() -> Self {
return Default::default();
}
}
pub struct PlayerFour {
pub what: f32,
pub wa: String,
pub hp: i32,
}
impl Default for PlayerFour {
fn default() -> Self {
Self {
what: 15.5,
wa: String::from("ament"),
hp: 20,
}
}
}
impl PlayerFour {
pub fn new() -> Self {
return Default::default();
}
}