chg: Changed some struct names

This commit is contained in:
Sayantan Santra 2024-03-31 16:07:33 -05:00
parent 4f80b1b522
commit 34518affaf
Signed by: SinTan1729
GPG Key ID: EB3E68BFBA25C85F
2 changed files with 6 additions and 6 deletions

View File

@ -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<String> {
.ok()
}
pub fn getall(db: &Connection) -> Vec<DbRow> {
pub fn getall(db: &Connection) -> Vec<DBRow> {
let mut statement = db.prepare_cached("SELECT * FROM urls").unwrap();
let mut data = statement.query([]).unwrap();
let mut links: Vec<DbRow> = Vec::new();
let mut links: Vec<DBRow> = 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(),

View File

@ -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"));