Skip to content

Commit eeb1120

Browse files
committed
updated print.rs
1 parent 2e8bec6 commit eeb1120

File tree

1 file changed

+10
-33
lines changed

1 file changed

+10
-33
lines changed

src/print.rs

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,14 @@
1-
pub mod print_fn {
2-
#![allow(warnings)]
3-
1+
pub mod print_fn
2+
{
43
// PACKAGES
54
use std::fs::File;
65
use std::error::Error;
76
use std::io::{prelude::*, BufReader};
87

9-
extern crate rusqlite;
10-
use rusqlite::{params, Connection, Result, NO_PARAMS};
11-
128
use serde::{Deserialize, Serialize};
139
use serde_yaml::{self};
1410
// PACKAGES
1511

16-
#[derive(Debug)]
17-
struct FileStr {
18-
id: i64,
19-
file_path: String,
20-
save_name: String,
21-
saved_date: String,
22-
saved_time: String
23-
}
2412

2513
#[derive(Debug, Serialize, Deserialize)]
2614
struct Config {
@@ -45,7 +33,7 @@ pub mod print_fn {
4533
}
4634

4735

48-
fn show_log() -> Result<(), std::io::Error> {
36+
fn show_log() -> std::io::Result<()> {
4937
let file = File::open("rustix/log.txt")?;
5038
let reader = BufReader::new(file);
5139
for line in reader.lines() { println!("{}", line?); }
@@ -63,27 +51,16 @@ pub mod print_fn {
6351
}
6452

6553

66-
fn print_db() -> Result<(), Box<dyn Error>> {
67-
let conn = Connection::open("rustix/storage.db3")?;
68-
let mut stmt = conn.prepare("SELECT * FROM main")?;
69-
70-
let mut base = stmt.query_map(NO_PARAMS, |row| {
71-
Ok(FileStr {
72-
id: row.get(0)?,
73-
file_path: row.get(1)?, save_name: row.get(2)?,
74-
saved_date: row.get(3)?, saved_time: row.get(4)?,
75-
})
76-
})?;
77-
78-
let mut new_base: Vec<FileStr> = Vec::new();
79-
for one in base.into_iter() { new_base.push(one.unwrap()); }
54+
fn print_db() {
55+
let SAVES_BASE = crate::database::get::start().unwrap();
56+
let mut id : i64 = 1;
8057

81-
for x in new_base.into_iter() {
58+
for x in SAVES_BASE.into_iter() {
8259
println!("{}. {}\n - path\n {}\n - saved\n {}\n {}\n",
83-
x.id, x.save_name, x.file_path, x.saved_date, x.saved_time);
84-
}
60+
id, x[1], x[0], x[2], x[3]);
8561

86-
Ok(())
62+
id += 1;
63+
}
8764
}
8865

8966

0 commit comments

Comments
 (0)