Remove 'allow unused' macro and handle the warnings therefrom

This commit is contained in:
flyingscorpio@clevo 2023-01-10 20:51:41 +01:00
parent 573ae6ef9a
commit b0704f50a4
5 changed files with 8 additions and 13 deletions

View file

@ -1,9 +1,6 @@
//! Holds the elements pertaining to ApiClient, a REST API client.
use std::fmt::Display;
use std::fs::read_to_string;
use std::io;
use std::process;
use reqwest::Url;
use serde_json::Value;

View file

@ -8,7 +8,7 @@ mod errors;
use diesel::prelude::*;
use crate::ear::Request;
use crate::models::{Favorite, History, InsertFavorite, InsertHistory, InsertTitle, Title};
use crate::models::{History, InsertFavorite, InsertHistory, InsertTitle, Title};
use crate::schema::title;
use crate::schema::title::dsl::*;
pub use errors::DatabaseError;

View file

@ -1,6 +1,6 @@
//! CRUD operations for the database.
use std::{env, option};
use std::env;
use diesel::pg::PgConnection;
use diesel::prelude::*;
@ -10,7 +10,6 @@ use crate::models::{Favorite, History, InsertFavorite, InsertHistory, InsertTitl
use crate::schema::favorite;
use crate::schema::favorite::dsl::*;
use crate::schema::history;
use crate::schema::history::dsl::*;
use crate::schema::title;
use crate::schema::title::dsl::*;

View file

@ -127,8 +127,11 @@ fn parse_uri(full_request: &str) -> Result<Request, ReqParseError> {
}
/// Handles a given well formed request
fn handle_request(request: Request, mut sender: Mouth) {
database::save_request_to_history(&request);
fn handle_request(request: Request, sender: Mouth) {
database::save_request_to_history(&request).unwrap_or_else(|err| {
eprintln!("{err}");
return;
});
match request.method {
HttpMethod::Get => handle_get_request(request, sender),

View file

@ -1,12 +1,9 @@
//! Hephaistos is a web application serving an API.
#![allow(unused)]
use std::error::Error;
use std::io::Write;
use std::{io, process};
use serde_json::Value;
mod api_client;
mod database;
mod ear;
@ -17,14 +14,13 @@ mod schema;
use api_client::ApiClient;
use ear::Ear;
use models::InsertTitle;
use mouth::Mouth;
/// Entry point of the library, propagates errors to `main`.
pub fn run() -> Result<(), Box<dyn Error>> {
// Start off by populating the local database with all Mirabel titles
// Make an API call to Mirabel to fetch all titles
print!("Updating the local database... ");
io::stdout().flush();
io::stdout().flush().expect("wasn't able to flush stdout");
let api_client = ApiClient::new();
let all_titles = api_client.get_titles().unwrap_or_else(|err| {
eprintln!("{err}");