Remove 'allow unused' macro and handle the warnings therefrom
This commit is contained in:
parent
573ae6ef9a
commit
b0704f50a4
5 changed files with 8 additions and 13 deletions
|
@ -1,9 +1,6 @@
|
||||||
//! Holds the elements pertaining to ApiClient, a REST API client.
|
//! Holds the elements pertaining to ApiClient, a REST API client.
|
||||||
|
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
use std::fs::read_to_string;
|
|
||||||
use std::io;
|
|
||||||
use std::process;
|
|
||||||
|
|
||||||
use reqwest::Url;
|
use reqwest::Url;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
|
@ -8,7 +8,7 @@ mod errors;
|
||||||
use diesel::prelude::*;
|
use diesel::prelude::*;
|
||||||
|
|
||||||
use crate::ear::Request;
|
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;
|
||||||
use crate::schema::title::dsl::*;
|
use crate::schema::title::dsl::*;
|
||||||
pub use errors::DatabaseError;
|
pub use errors::DatabaseError;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//! CRUD operations for the database.
|
//! CRUD operations for the database.
|
||||||
|
|
||||||
use std::{env, option};
|
use std::env;
|
||||||
|
|
||||||
use diesel::pg::PgConnection;
|
use diesel::pg::PgConnection;
|
||||||
use diesel::prelude::*;
|
use diesel::prelude::*;
|
||||||
|
@ -10,7 +10,6 @@ use crate::models::{Favorite, History, InsertFavorite, InsertHistory, InsertTitl
|
||||||
use crate::schema::favorite;
|
use crate::schema::favorite;
|
||||||
use crate::schema::favorite::dsl::*;
|
use crate::schema::favorite::dsl::*;
|
||||||
use crate::schema::history;
|
use crate::schema::history;
|
||||||
use crate::schema::history::dsl::*;
|
|
||||||
use crate::schema::title;
|
use crate::schema::title;
|
||||||
use crate::schema::title::dsl::*;
|
use crate::schema::title::dsl::*;
|
||||||
|
|
||||||
|
|
|
@ -127,8 +127,11 @@ fn parse_uri(full_request: &str) -> Result<Request, ReqParseError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handles a given well formed request
|
/// Handles a given well formed request
|
||||||
fn handle_request(request: Request, mut sender: Mouth) {
|
fn handle_request(request: Request, sender: Mouth) {
|
||||||
database::save_request_to_history(&request);
|
database::save_request_to_history(&request).unwrap_or_else(|err| {
|
||||||
|
eprintln!("{err}");
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
|
||||||
match request.method {
|
match request.method {
|
||||||
HttpMethod::Get => handle_get_request(request, sender),
|
HttpMethod::Get => handle_get_request(request, sender),
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
//! Hephaistos is a web application serving an API.
|
//! Hephaistos is a web application serving an API.
|
||||||
|
|
||||||
#![allow(unused)]
|
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::{io, process};
|
use std::{io, process};
|
||||||
|
|
||||||
use serde_json::Value;
|
|
||||||
|
|
||||||
mod api_client;
|
mod api_client;
|
||||||
mod database;
|
mod database;
|
||||||
mod ear;
|
mod ear;
|
||||||
|
@ -17,14 +14,13 @@ mod schema;
|
||||||
use api_client::ApiClient;
|
use api_client::ApiClient;
|
||||||
use ear::Ear;
|
use ear::Ear;
|
||||||
use models::InsertTitle;
|
use models::InsertTitle;
|
||||||
use mouth::Mouth;
|
|
||||||
|
|
||||||
/// Entry point of the library, propagates errors to `main`.
|
/// Entry point of the library, propagates errors to `main`.
|
||||||
pub fn run() -> Result<(), Box<dyn Error>> {
|
pub fn run() -> Result<(), Box<dyn Error>> {
|
||||||
// Start off by populating the local database with all Mirabel titles
|
// Start off by populating the local database with all Mirabel titles
|
||||||
// Make an API call to Mirabel to fetch all titles
|
// Make an API call to Mirabel to fetch all titles
|
||||||
print!("Updating the local database... ");
|
print!("Updating the local database... ");
|
||||||
io::stdout().flush();
|
io::stdout().flush().expect("wasn't able to flush stdout");
|
||||||
let api_client = ApiClient::new();
|
let api_client = ApiClient::new();
|
||||||
let all_titles = api_client.get_titles().unwrap_or_else(|err| {
|
let all_titles = api_client.get_titles().unwrap_or_else(|err| {
|
||||||
eprintln!("{err}");
|
eprintln!("{err}");
|
||||||
|
|
Loading…
Reference in a new issue