Skip to content

Commit 7097ef1

Browse files
committed
fix: fix some build warnings
1 parent 59cbdf4 commit 7097ef1

File tree

4 files changed

+4
-68
lines changed

4 files changed

+4
-68
lines changed

src/auth/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ pub enum AuthenticationError {
66
NoToken,
77
#[error("Provided token is invalid")]
88
InvalidToken,
9-
#[error("User didn't accept authentication")]
10-
UserRejectedAuth,
119
#[error("User auth pending")]
1210
UserAuthPending,
1311
#[error("Failed to communicate with GitHub")]

src/types/api.rs

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,20 @@
1-
use std::error::Error;
2-
use actix_web::{error::QueryPayloadError, http::header::ContentType, HttpRequest, HttpResponse};
1+
use actix_web::{error::QueryPayloadError, HttpRequest};
32
use serde::{Deserialize, Serialize};
4-
use std::fmt::Display;
5-
use actix_web::http::StatusCode;
3+
4+
use crate::endpoints::ApiError;
65

76
#[derive(Serialize, Deserialize)]
87
pub struct PaginatedData<T> {
98
pub data: Vec<T>,
109
pub count: i64,
1110
}
1211

13-
#[derive(Debug, PartialEq)]
14-
pub enum ApiError {
15-
FilesystemError,
16-
DbAcquireError,
17-
DbError,
18-
TransactionError,
19-
InternalError,
20-
BadRequest(String),
21-
NotFound(String),
22-
Unauthorized,
23-
Forbidden,
24-
}
25-
2612
#[derive(Debug, Serialize, Deserialize)]
2713
pub struct ApiResponse<T> {
2814
pub error: String,
2915
pub payload: T,
3016
}
3117

32-
impl Error for ApiError {}
33-
34-
impl Display for ApiError {
35-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
36-
match self {
37-
Self::FilesystemError => write!(f, "Unknown filesystem error"),
38-
Self::DbAcquireError => write!(f, "Database is busy"),
39-
Self::DbError => write!(f, "Unknown database error"),
40-
Self::TransactionError => write!(f, "Unknown transaction error"),
41-
Self::BadRequest(message) => write!(f, "{}", message),
42-
Self::NotFound(message) => write!(f, "{}", message),
43-
Self::InternalError => write!(f, "Internal server error"),
44-
Self::Forbidden => write!(f, "You cannot perform this action"),
45-
Self::Unauthorized => write!(f, "You need to be authenticated to perform this action"),
46-
}
47-
}
48-
}
49-
50-
impl actix_web::ResponseError for ApiError {
51-
fn status_code(&self) -> StatusCode {
52-
match self {
53-
Self::FilesystemError => StatusCode::INTERNAL_SERVER_ERROR,
54-
Self::DbAcquireError => StatusCode::INTERNAL_SERVER_ERROR,
55-
Self::DbError => StatusCode::INTERNAL_SERVER_ERROR,
56-
Self::TransactionError => StatusCode::INTERNAL_SERVER_ERROR,
57-
Self::BadRequest(_) => StatusCode::BAD_REQUEST,
58-
Self::NotFound(_) => StatusCode::NOT_FOUND,
59-
Self::InternalError => StatusCode::INTERNAL_SERVER_ERROR,
60-
Self::Unauthorized => StatusCode::UNAUTHORIZED,
61-
Self::Forbidden => StatusCode::FORBIDDEN,
62-
}
63-
}
64-
fn error_response(&self) -> HttpResponse<actix_web::body::BoxBody> {
65-
HttpResponse::build(self.status_code())
66-
.append_header(ContentType::json())
67-
.json(ApiResponse {
68-
error: self.to_string(),
69-
payload: "".to_string(),
70-
})
71-
}
72-
}
73-
7418
pub fn query_error_handler(err: QueryPayloadError, _req: &HttpRequest) -> actix_web::Error {
7519
ApiError::BadRequest(err.to_string()).into()
7620
}

src/types/models/mod_version.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ impl ModVersion {
457457
query_builder.push_bind(id);
458458
query_builder.push(") q WHERE q.rn = 1");
459459

460-
let mut version = query_builder
460+
let version = query_builder
461461
.build_query_as::<ModVersionGetOne>()
462462
.fetch_optional(&mut *pool)
463463
.await

src/types/models/tag.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ use crate::database::repository::mod_tags;
44
use crate::{database::DatabaseError, endpoints::ApiError};
55
use sqlx::PgConnection;
66

7-
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
8-
pub struct FetchedTag {
9-
pub id: i32,
10-
pub name: String,
11-
}
12-
137
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
148
pub struct Tag {
159
pub id: i32,

0 commit comments

Comments
 (0)