From 34518affaf92da9059407280ce77848e851fd135 Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Sun, 31 Mar 2024 16:07:33 -0500 Subject: [PATCH] chg: Changed some struct names --- actix/src/database.rs | 8 ++++---- actix/src/utils.rs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/actix/src/database.rs b/actix/src/database.rs index 0dc66a1..14c5ff5 100644 --- a/actix/src/database.rs +++ b/actix/src/database.rs @@ -2,7 +2,7 @@ use rusqlite::Connection; use serde::Serialize; #[derive(Serialize)] -pub struct DbRow { +pub struct DBRow { shortlink: String, longlink: String, hits: i64, @@ -18,14 +18,14 @@ pub fn find_url(shortlink: &str, db: &Connection) -> Option { .ok() } -pub fn getall(db: &Connection) -> Vec { +pub fn getall(db: &Connection) -> Vec { let mut statement = db.prepare_cached("SELECT * FROM urls").unwrap(); let mut data = statement.query([]).unwrap(); - let mut links: Vec = Vec::new(); + let mut links: Vec = Vec::new(); while let Some(row) = data.next().unwrap() { - let row_struct = DbRow { + let row_struct = DBRow { shortlink: row.get("short_url").unwrap(), longlink: row.get("long_url").unwrap(), hits: row.get("hits").unwrap(), diff --git a/actix/src/utils.rs b/actix/src/utils.rs index 68bad35..d9fb977 100644 --- a/actix/src/utils.rs +++ b/actix/src/utils.rs @@ -8,7 +8,7 @@ use rusqlite::Connection; use serde::Deserialize; #[derive(Deserialize)] -struct Url { +struct URLPair { shortlink: String, longlink: String, } @@ -32,7 +32,7 @@ pub fn getall(db: &Connection) -> String { } pub fn add_link(req: String, db: &Connection) -> (bool, String) { - let mut chunks: Url = serde_json::from_str(&req).unwrap(); + let mut chunks: URLPair = serde_json::from_str(&req).unwrap(); let style = env::var("slug_style").unwrap_or(String::from("Pair")); let len_str = env::var("slug_length").unwrap_or(String::from("8"));