From 333d5e6981008ac2ce02165f203f4aaeff359767 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Sun, 5 May 2024 18:41:31 +0200 Subject: [PATCH] Implements basic traits and serialization --- helper_config.toml | 58 ++++++-- src/main.rs | 5 +- src/table_structs.rs | 203 +------------------------- src/table_types.rs | 335 +++++++++++++++++++++++++++++++++++++++++++ src/tablegen.rs | 38 +++-- 5 files changed, 405 insertions(+), 234 deletions(-) create mode 100644 src/table_types.rs diff --git a/helper_config.toml b/helper_config.toml index 18e965a..993c2e0 100644 --- a/helper_config.toml +++ b/helper_config.toml @@ -17,16 +17,56 @@ header_food = '''{\footnotesize \rowcolors{2}{gray!25}{white} \begin{tabularx}{\textwidth}{|p{0.17\linewidth\hyphenpenalty=9000}lp{0.13\linewidth}p{0.042\linewidth}X|} \hline\rowcolor{gray!50}\hline -Ingrédient&Partie&Rareté&Satiété&Effet&(Plat)&Effets&(Accompagnement)&Difficulté&Toxicité \\ +Ingrédient&Partie&Rareté&Satiété&Effet (Plat)&Effets (Accompagnement)&Difficulté&Toxicité \\ + \hline''' +header_alchemy = '''{\footnotesize + \rowcolors{2}{gray!25}{white} + \begin{tabularx}{\textwidth}{|p{0.17\linewidth\hyphenpenalty=9000}lp{0.13\linewidth}p{0.042\linewidth}X|} + \hline\rowcolor{gray!50}\hline + Ingrédient & Partie & Rareté & Effet (Principal) & Effets (Catalysé) & Difficulté & Toxicité + \hline''' +header_forge = '''{\footnotesize + \rowcolors{2}{gray!25}{white} + \begin{tabularx}{\textwidth}{|p{0.17\linewidth\hyphenpenalty=9000}lp{0.13\linewidth}p{0.042\linewidth}X|} + \hline\rowcolor{gray!50}\hline +Ingrédient & Rareté & Densité & Effet Armes (Principal) & Effet Armures (Principal) & Effets Armes (Catalysé) & Effet Armures (C) & Difficulté & Préparation + \hline''' +header_mtrap ='''{\footnotesize + \rowcolors{2}{gray!25}{white} + \begin{tabularx}{\textwidth}{|p{0.17\linewidth\hyphenpenalty=9000}lp{0.13\linewidth}p{0.042\linewidth}X|} + \hline\rowcolor{gray!50}\hline +Élément & Prix & Effet & Difficulté & Activation & Solidité + \hline''' +header_weapons = '''{\footnotesize + \rowcolors{2}{gray!25}{white} + \begin{tabularx}{\textwidth}{|p{0.17\linewidth\hyphenpenalty=9000}lp{0.13\linewidth}p{0.042\linewidth}X|} + \hline\rowcolor{gray!50}\hline +Nom & Rareté & Dégâts & + & R.Max & Armor.B & Prot & Int. & Deux M & Une M & Esq. & Parr. & Vitesse & Discrétion & Catégorie & Modes & Spécial + \hline''' +header_armors ='''{\footnotesize + \rowcolors{2}{gray!25}{white} + \begin{tabularx}{\textwidth}{|p{0.17\linewidth\hyphenpenalty=9000}lp{0.13\linewidth}p{0.042\linewidth}X|} + \hline\rowcolor{gray!50}\hline +Nom & Rareté & Dégâts & + & R.Max & Armor.B & Prot & Int. & Deux M & Une M & Esq. & Parr. & Vitesse & Discrétion & Spécial + \hline''' +header_gadgets ='''{\footnotesize + \rowcolors{2}{gray!25}{white} + \begin{tabularx}{\textwidth}{|p{0.17\linewidth\hyphenpenalty=9000}lp{0.13\linewidth}p{0.042\linewidth}X|} + \hline\rowcolor{gray!50}\hline +Nom & Effet & Prix + \hline''' +header_potions = '''{\footnotesize + \rowcolors{2}{gray!25}{white} + \begin{tabularx}{\textwidth}{|p{0.17\linewidth\hyphenpenalty=9000}lp{0.13\linewidth}p{0.042\linewidth}X|} + \hline\rowcolor{gray!50}\hline +Nom & Type & Prix & Toxicité & Effet + \hline''' +header_traps = '''{\footnotesize + \rowcolors{2}{gray!25}{white} + \begin{tabularx}{\textwidth}{|p{0.17\linewidth\hyphenpenalty=9000}lp{0.13\linewidth}p{0.042\linewidth}X|} + \hline\rowcolor{gray!50}\hline +Nom & Type & Prix & Toxicité & Effet \hline''' -header_alchemy = "" -header_forge = "" -header_mtrap = "" -header_weapons = "" -header_armors = "" -header_gadgets = "" -header_potions = "" -header_traps = "" end = ''' \hline \end{tabularx} }''' diff --git a/src/main.rs b/src/main.rs index 8c8e4c0..495a312 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,10 +3,11 @@ //! This program is meant as a helper for the ravenous project. //! -#![allow(dead_code)] +// #![allow(dead_code)] #![warn(missing_docs)] -// #![warn(clippy::missing_docs_in_private_items)] +#![warn(clippy::missing_docs_in_private_items)] mod table_structs; +mod table_types; mod tablegen; use crate::table_structs::TableArgs; use std::fs; diff --git a/src/table_structs.rs b/src/table_structs.rs index daa4c6d..8c172c7 100644 --- a/src/table_structs.rs +++ b/src/table_structs.rs @@ -1,15 +1,8 @@ //! Holds all the data structures away from the main routine -use crate::{tablegen::make_latex_string, Config}; -use anyhow::{Context, Result}; use clap::Args; -use dynfmt::{Format, SimpleCurlyFormat}; use phf::phf_map; use regex::Regex; -use serde::Deserialize; -use std::{ - fmt::{self, Debug, Display}, - io::{BufWriter, Write}, -}; +use std::fmt::Debug; use regex_static::once_cell::sync::Lazy; @@ -99,197 +92,3 @@ impl From<&str> for TargetType { } } } - -#[derive(Debug, Deserialize)] -#[serde(rename_all = "PascalCase")] -/// A single row in a martial class tsv file -pub struct RecordClass { - /// The name of a technique. - pub technique: String, - /// The level or rank of a technique - pub niveau: String, - /// The type of technique, such as Actif or Exclusif. - pub technique_type: String, - /// The blood cost for this technique. - pub cout_blood: CleanString, - /// The gauge cost for this technique. - pub cout_jauge: CleanString, - /// A brief description of the effect or outcome of using this technique. - pub effet: CleanString, -} - -// impl Display for RecordClass { -// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { -// write!( -// f, -// " {}&{}&{}&{}{}&{} \\\\", -// self.technique, -// self.niveau, -// self.technique_type, -// self.cout_blood, -// self.cout_jauge, -// self.effet -// ) -// } -// } -impl WriteRow for RecordClass { - fn write_header(&self, _buffer: &mut BufWriter>, _configg: &Config) -> Result<()> { - unimplemented!() - } - - fn write_row(&self, buffer: &mut BufWriter>, _config: &Config) -> Result<()> { - Ok(write!( - buffer, - " {}&{}&{}&{}{}&{} \\\\", - self.technique, - self.niveau, - self.technique_type, - self.cout_blood, - self.cout_jauge, - self.effet - )?) - } - - fn write_footer(&self, _buffer: &mut BufWriter>, _configg: &Config) -> Result<()> { - unimplemented!() - } -} -/// Represents the whole Classes Array, with a vec for every tier -pub(crate) struct ClassesArray { - /// Every tier held as a vec of vec of rows - pub tiers: Vec>, -} - -/// Trait needed to be writable as a LaTex table -pub(crate) trait WriteTable { - /// Takes a config and writes to a string the representation of the Array - fn write_table(&self, config: &Config) -> Result; -} -/// Trait needed to be writable as a LaTex table -pub(crate) trait WriteRow { - fn write_header(&self, buffer: &mut BufWriter>, config: &Config) -> Result<()>; - fn write_row(&self, buffer: &mut BufWriter>, config: &Config) -> Result<()>; - fn write_footer(&self, buffer: &mut BufWriter>, config: &Config) -> Result<()>; -} -// pub(crate) trait WriteRows { -// /// Takes a config and writes to a string the representation of the Array -// fn write_rows(&self, config: &Config) -> Result; -// } - -impl WriteTable for ClassesArray { - fn write_table(&self, config: &Config) -> Result { - let mut buffer = BufWriter::new(Vec::new()); - for (lvl, tier) in self.tiers.iter().skip(1).enumerate() { - // rt_write!(buffer, config.classes.header, lvl + 1)?; - let formatted_header = SimpleCurlyFormat - .format(&config.classes.header, [lvl + 1]) - .expect("Formatting failed"); - writeln!(buffer, "{}", formatted_header)?; - writeln!(buffer, "{}", config.classes.row)?; - for elem in tier { - elem.write_row(&mut buffer, config)? - } - writeln!(buffer, "{}", config.classes.end)?; - } - Ok(String::from_utf8(buffer.into_inner()?).unwrap()) - } -} - -#[derive(Debug, Deserialize)] -#[serde(rename_all = "PascalCase")] -/// A single row in a martial class tsv file -pub struct RecordFood { - pub ingredient: String, - pub part: String, - pub rarity: CleanString, - pub filling: CleanString, - pub effect_main: CleanString, - pub effect_secondary: CleanString, - pub difficulty: CleanString, - pub toxicity: CleanString, -} - -impl Display for RecordFood { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!( - f, - " {}&{}&{}{}&{}&{}&{}&{} \\\\", - self.ingredient, - self.part, - self.rarity, - self.filling, - self.effect_main, - self.effect_secondary, - self.difficulty, - self.toxicity, - ) - } -} - -impl WriteRow for RecordFood { - fn write_header(&self, buffer: &mut BufWriter>, config: &Config) -> Result<()> { - writeln!(buffer, "{}", config.craft.header_food).context("Writing header") - - // Ok(String::from_utf8(buffer.into_inner()?).unwrap()) - } - fn write_row(&self, buffer: &mut BufWriter>, _config: &Config) -> Result<()> { - write!( - buffer, - " {}&{}&{}{}&{}&{}&{}&{} \\\\", - self.ingredient, - self.part, - self.rarity, - self.filling, - self.effect_main, - self.effect_secondary, - self.difficulty, - self.toxicity, - ) - .context("Writing row") - } - - fn write_footer(&self, buffer: &mut BufWriter>, config: &Config) -> Result<()> { - writeln!(buffer, "{}", config.craft.end).context("Writing footer") - } -} - -/// Represents the whole Craft Array, with a vec for every tier -pub(crate) struct CraftArray -where - RecordType: WriteRow, -{ - /// Every tier held as a vec of vec of rows - pub row: Vec, -} - -impl WriteTable for CraftArray -where - RecordType: WriteRow, -{ - fn write_table(&self, config: &Config) -> Result { - let mut buffer = BufWriter::new(Vec::new()); - self.row[0].write_header(&mut buffer, config)?; - for row in self.row.iter() { - row.write_row(&mut buffer, config)?; - } - self.row[0].write_footer(&mut buffer, config)?; - Ok(String::from_utf8(buffer.into_inner()?).unwrap()) - } -} -/// This type is used to represent strings in LaTeX tables, where certain characters need to be escaped or replaced with special commands. -#[derive(Deserialize)] -pub struct CleanString(String); - -impl fmt::Debug for CleanString { - #[inline] - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - ::fmt(&self.0, f) - } -} - -impl fmt::Display for CleanString { - #[inline] - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - f.write_str(&make_latex_string(&self.0)) - } -} diff --git a/src/table_types.rs b/src/table_types.rs new file mode 100644 index 0000000..6a73e0a --- /dev/null +++ b/src/table_types.rs @@ -0,0 +1,335 @@ +//! Holds all the table base structure +use crate::{tablegen::make_latex_string, Config}; +use anyhow::{Context, Result}; +use dynfmt::{Format, SimpleCurlyFormat}; +use serde::Deserialize; +use std::{ + fmt::{self, Debug}, + io::{BufWriter, Write}, +}; + +#[derive(Debug, Deserialize)] +#[serde(rename_all = "PascalCase")] +/// A single row in a martial class tsv file +pub(crate) struct RecordClass { + /// The name of a technique. + pub technique: String, + /// The level or rank of a technique + pub niveau: String, + /// The type of technique, such as Actif or Exclusif. + pub technique_type: String, + /// The blood cost for this technique. + pub cout_blood: CleanString, + /// The gauge cost for this technique. + pub cout_jauge: CleanString, + /// A brief description of the effect or outcome of using this technique. + pub effet: CleanString, +} + +impl WriteRow for RecordClass { + fn write_header(&self, _buffer: &mut BufWriter>, _configg: &Config) -> Result<()> { + unimplemented!() + } + + fn write_row(&self, buffer: &mut BufWriter>, _config: &Config) -> Result<()> { + Ok(write!( + buffer, + " {}&{}&{}&{}{}&{} \\\\", + self.technique, + self.niveau, + self.technique_type, + self.cout_blood, + self.cout_jauge, + self.effet + )?) + } + + fn write_footer(&self, _buffer: &mut BufWriter>, _configg: &Config) -> Result<()> { + unimplemented!() + } +} +/// Represents the whole Classes Array, with a vec for every tier +pub(crate) struct ClassesArray { + /// Every tier held as a vec of vec of rows + pub tiers: Vec>, +} + +/// Trait needed to be writable as a LaTex table +pub(crate) trait WriteTable { + /// Takes a config and writes to a string the representation of the Array + fn write_table(&self, config: &Config) -> Result; +} +/// Trait needed to be writable as a LaTex table +pub(crate) trait WriteRow { + /// Write the header of the LaTex table + fn write_header(&self, buffer: &mut BufWriter>, config: &Config) -> Result<()>; + /// Write the row of the LaTex table + fn write_row(&self, buffer: &mut BufWriter>, config: &Config) -> Result<()>; + /// Write the row of the LaTex table + fn write_footer(&self, buffer: &mut BufWriter>, config: &Config) -> Result<()>; +} + +impl WriteTable for ClassesArray { + fn write_table(&self, config: &Config) -> Result { + let mut buffer = BufWriter::new(Vec::new()); + for (lvl, tier) in self.tiers.iter().skip(1).enumerate() { + // rt_write!(buffer, config.classes.header, lvl + 1)?; + let formatted_header = SimpleCurlyFormat + .format(&config.classes.header, [lvl + 1]) + .expect("Formatting failed"); + writeln!(buffer, "{}", formatted_header)?; + writeln!(buffer, "{}", config.classes.row)?; + for elem in tier { + elem.write_row(&mut buffer, config)? + } + writeln!(buffer, "{}", config.classes.end)?; + } + Ok(String::from_utf8(buffer.into_inner()?).unwrap()) + } +} + +/// Represents the whole Craft Array, with a vec for every tier +pub(crate) struct CraftArray +where + RecordType: WriteRow, +{ + /// Every tier held as a vec of vec of rows + pub row: Vec, +} + +impl WriteTable for CraftArray +where + RecordType: WriteRow, +{ + fn write_table(&self, config: &Config) -> Result { + let mut buffer = BufWriter::new(Vec::new()); + self.row[0].write_header(&mut buffer, config)?; + for row in self.row.iter() { + row.write_row(&mut buffer, config)?; + } + self.row[0].write_footer(&mut buffer, config)?; + Ok(String::from_utf8(buffer.into_inner()?).unwrap()) + } +} + +/// This type is used to represent strings in LaTeX tables, where certain characters need to be escaped or replaced with special commands. +#[derive(Deserialize)] +pub(crate) struct CleanString(String); + +impl fmt::Debug for CleanString { + #[inline] + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + ::fmt(&self.0, f) + } +} + +impl fmt::Display for CleanString { + #[inline] + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.write_str(&make_latex_string(&self.0)) + } +} + +#[derive(Debug, Deserialize)] +#[serde(rename_all = "PascalCase")] +/// A single row in a martial class tsv file +pub(crate) struct RecordFood { + /// The name of the ingredient used in this recipe. + pub ingredient: String, + + /// The part of the body this food is from. + pub part: String, + + /// The rarity level of this food, represented as a clean string. + pub rarity: CleanString, + + /// How much this this food item will fill you. + pub filling: CleanString, + + /// The main effect that this food has on the player's character (e.g. "healing", "buffing", etc.). + pub effect_main: CleanString, + + /// Any secondary effects that this food may have on the player's character. + pub effect_secondary: CleanString, + + /// A measure of how difficult it is to prepare this food item. + pub difficulty: CleanString, + + /// The toxicity level of this food. + pub toxicity: CleanString, +} + +impl WriteRow for RecordFood { + fn write_header(&self, buffer: &mut BufWriter>, config: &Config) -> Result<()> { + writeln!(buffer, "{}", config.craft.header_food).context("Writing header") + + // Ok(String::from_utf8(buffer.into_inner()?).unwrap()) + } + fn write_row(&self, buffer: &mut BufWriter>, _config: &Config) -> Result<()> { + writeln!( + buffer, + " {}&{}&{}{}&{}&{}&{}&{} \\\\", + self.ingredient, + self.part, + self.rarity, + self.filling, + self.effect_main, + self.effect_secondary, + self.difficulty, + self.toxicity, + ) + .context("Writing row") + } + + fn write_footer(&self, buffer: &mut BufWriter>, config: &Config) -> Result<()> { + writeln!(buffer, "{}", config.craft.end).context("Writing footer") + } +} + +#[derive(Debug, Deserialize)] +#[serde(rename_all = "PascalCase")] +/// A record of alchemy data. +pub(crate) struct RecordAlchemy { + /// The ingredients name. + pub ingredient: String, + + /// The part this ingredient came from + pub part: String, + + /// The rarity level of this alchemy + pub rarity: CleanString, + + /// A brief description of the main effect of this alchemy. + pub effect_main: CleanString, + + /// A brief description of any secondary effects of this alchemy. + pub effect_secondary: CleanString, + + /// The difficulty level required to perform this alchemy + pub difficulty: CleanString, + + /// The toxicity of this ingredient. + pub toxicity: CleanString, +} + +impl WriteRow for RecordAlchemy { + fn write_header(&self, buffer: &mut BufWriter>, config: &Config) -> Result<()> { + writeln!(buffer, "{}", config.craft.header_alchemy).context("Writing header") + } + fn write_row(&self, buffer: &mut BufWriter>, _config: &Config) -> Result<()> { + writeln!( + buffer, + " {}&{}&{}{}&{}&{}&{} \\\\", + self.ingredient, + self.part, + self.rarity, + self.effect_main, + self.effect_secondary, + self.difficulty, + self.toxicity, + ) + .context("Writing row") + } + + fn write_footer(&self, buffer: &mut BufWriter>, config: &Config) -> Result<()> { + writeln!(buffer, "{}", config.craft.end).context("Writing footer") + } +} + +#[derive(Debug, Deserialize)] +#[serde(rename_all = "PascalCase")] +/// A record of alchemy data. +pub(crate) struct RecordForge { + /// The ingredient used in this forging recipe. + pub ingredient: String, + + /// The rarity level of this forged item. + pub rarity: CleanString, + + /// The density or weight class of the forged item. + pub density: CleanString, + + /// Main effect on weapons when using this ingredient. + pub effect_weapon_main: CleanString, + + /// Main effect on armor when using this ingredient. + pub effect_armor_main: CleanString, + + /// Secondary effects on weapons when using this ingredient. + pub effect_weapon_secondary: CleanString, + + /// Secondary effects on armor when using this ingredient. + pub effect_armor_secondary: CleanString, + + /// The difficulty level + pub difficulty: CleanString, + + /// The difficulty processing this ingredient. + pub preparation: CleanString, +} + +impl WriteRow for RecordForge { + fn write_header(&self, buffer: &mut BufWriter>, config: &Config) -> Result<()> { + writeln!(buffer, "{}", config.craft.header_forge).context("Writing header") + } + fn write_row(&self, buffer: &mut BufWriter>, _config: &Config) -> Result<()> { + writeln!( + buffer, + " {}&{}&{}&{}&{}{}&{}&{}&{} \\\\", + self.ingredient, + self.rarity, + self.density, + self.effect_weapon_main, + self.effect_armor_main, + self.effect_weapon_secondary, + self.effect_armor_secondary, + self.difficulty, + self.preparation, + ) + .context("Writing row") + } + + fn write_footer(&self, buffer: &mut BufWriter>, config: &Config) -> Result<()> { + writeln!(buffer, "{}", config.craft.end).context("Writing footer") + } +} + +// #[derive(Debug, Deserialize)] +// #[serde(rename_all = "PascalCase")] +// pub(crate) struct Weapons { +// name: String, +// rarity: CleanString, +// damage: String, +// damage_add: String, +// rmax: String, +// armorbreak: String, +// protection: String, +// integrity: String, +// twohanded: String, +// onehanded: String, +// dodge: String, +// } + +// impl WriteRow for Weapons { +// fn write_header(&self, buffer: &mut BufWriter>, config: &Config) -> Result<()> { +// writeln!(buffer, "{}", config.craft.header_alchemy).context("Writing header") +// } +// fn write_row(&self, buffer: &mut BufWriter>, _config: &Config) -> Result<()> { +// writeln!( +// buffer, +// " {}&{}&{}{}&{}&{}&{} \\\\", +// self.ingredient, +// self.part, +// self.rarity, +// self.effect_main, +// self.effect_secondary, +// self.difficulty, +// self.toxicity, +// ) +// .context("Writing row") +// } + +// fn write_footer(&self, buffer: &mut BufWriter>, config: &Config) -> Result<()> { +// writeln!(buffer, "{}", config.craft.end).context("Writing footer") +// } +// } diff --git a/src/tablegen.rs b/src/tablegen.rs index e4bf2e1..543911a 100644 --- a/src/tablegen.rs +++ b/src/tablegen.rs @@ -9,11 +9,12 @@ use std::{ path::{Path, PathBuf}, }; +use crate::table_types::{ + ClassesArray, CraftArray, RecordAlchemy, RecordClass, RecordFood, RecordForge, WriteRow, + WriteTable, +}; use crate::{ - table_structs::{ - ClassesArray, CraftArray, RecordClass, RecordFood, TableArgs, TableTargets, TargetType, - WriteRow, WriteTable, RE, STR_TO_TARGET_FULL, - }, + table_structs::{TableArgs, TableTargets, TargetType, RE, STR_TO_TARGET_FULL}, Config, }; @@ -54,23 +55,18 @@ fn process_one_file(f: &mut PathBuf, args: &TableArgs, config: &Config) -> Resul let tt = extract_type(f).context("Error extracting file type ... skipping")?; let tsv: Box = match tt { TableTargets::Classes => Box::new(read_tsv_classes(f)?), - _ => read_tsv::(f, tt)?, - }; - - match tt { - TableTargets::Classes => export_tsv(f, tsv, args, config), - TableTargets::Food => export_tsv(f, tsv, args, config), - TableTargets::Alchemy => todo!(), - TableTargets::Forge => todo!(), + TableTargets::Food => read_tsv::(f)?, + TableTargets::Alchemy => read_tsv::(f)?, + TableTargets::Forge => read_tsv::(f)?, TableTargets::MPieges => todo!(), TableTargets::Weapons => todo!(), TableTargets::Armors => todo!(), TableTargets::Gadgets => todo!(), TableTargets::Potions => todo!(), TableTargets::Traps => todo!(), - // TableTargets::Classes => todo!(), - } - .context("Error exporting the tsv") + }; + + export_tsv(f, tsv, args, config).context("Error exporting the tsv") } #[inline] @@ -126,6 +122,7 @@ pub fn make_latex_string(arg: &str) -> String { let temp = arg .replace('🩸', "\\blood") .replace('⚡', "\\gauge") + .replace('☆', "\\star") .replace('&', "\\&"); let res = RE.replace_all(&temp, |caps: &Captures| { format!("\\dd{{{}}}", caps[0].chars().count()) @@ -135,7 +132,7 @@ pub fn make_latex_string(arg: &str) -> String { /// Reads a TSV file into a table. /// -/// This function reads in a comma-separated values (TSV) file and returns it as a Table object, +/// This function reads in a tab-separated values (TSV) file and returns it as a Table object, /// which can be used to generate LaTeX code or perform other operations on the data. fn read_tsv_classes(filename: &T) -> Result where @@ -170,12 +167,11 @@ where /// Reads a TSV file into a table. /// -/// This function reads in a comma-separated values (TSV) file and returns it as a Table object, -/// which can be used to generate LaTeX code or perform other operations on the data. -fn read_tsv(filename: &Path, target_type: &TableTargets) -> Result> +/// Reads a tab-separated values (TSV) file and deserializes its contents into a table. +fn read_tsv(filename: &Path) -> Result> where + // TODO: Remove the static and do not return a Box RecordType: for<'a> serde::Deserialize<'a> + WriteRow + 'static, - // RecordHolder: WriteRows, { let file = File::open(filename)?; let mut rdr = csv::ReaderBuilder::new() @@ -188,7 +184,7 @@ where .from_reader(file); let mut levels = Vec::with_capacity(30); - for result in rdr.deserialize() { + for result in rdr.deserialize().skip(2) { let result: RecordType = result?; levels.push(result); }