feat: base project structure

This commit is contained in:
Ahmet Kaan Gümüş 2025-05-14 23:43:35 +03:00
parent e2043f1009
commit 1567a9c32a
15 changed files with 5568 additions and 1 deletions

8
protocol/Cargo.toml Normal file
View file

@ -0,0 +1,8 @@
[package]
name = "protocol"
version = "0.1.0"
edition = "2024"
[dependencies]
serde = { workspace = true }
chrono = { workspace = true }

39
protocol/src/lib.rs Normal file
View file

@ -0,0 +1,39 @@
use std::{collections::VecDeque, fs::File, io::Read};
pub const BUFFER_LENGTH: usize = 1024;
#[derive(Debug, Clone)]
struct TOML {
header: String,
fields: VecDeque<String>,
}
fn naive_toml_parser(file_location: &str) -> TOML {
let mut toml_file = File::open(file_location).unwrap();
let mut toml_ingredients = String::default();
toml_file.read_to_string(&mut toml_ingredients).unwrap();
let mut toml_ingredients = toml_ingredients.lines().collect::<VecDeque<&str>>();
let header = toml_ingredients
.pop_front()
.unwrap()
.replace('[', "")
.replace(']', "")
.trim_end()
.to_string();
let fields = toml_ingredients
.iter()
.map(|ingredient| {
ingredient
.split_once('=')
.unwrap()
.1
.replace('"', "")
.trim()
.to_string()
})
.collect();
TOML { header, fields }
}