From 497436579ffb622c63f3bd8cdc66b6932cd7ab45 Mon Sep 17 00:00:00 2001 From: Coin de Gamma Date: Thu, 5 Sep 2024 09:33:23 +0000 Subject: [PATCH] Item structure begin --- src/db.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/db.rs b/src/db.rs index 48210fd..3601c4d 100644 --- a/src/db.rs +++ b/src/db.rs @@ -1,13 +1,29 @@ use std::collections::HashSet; +use std::hash::{Hash}; use std::fs; use std::io::{self, Write, BufRead}; +// TODO: use this structure in HashSet of items +#[derive(Debug, PartialEq, Eq, Hash)] +pub struct Item { + pub id: String, + pub content: String +} + +impl Item { + pub fn from(s: String) -> Item { + Item { id: s, content: String::from("") } + } +} + + pub struct DB { pub items: HashSet:: } + impl DB { pub fn new(path: &str) -> io::Result { let file = fs::File::open(path)?;