Skip to content

Commit

Permalink
Rename some structs and traits
Browse files Browse the repository at this point in the history
  • Loading branch information
welf committed Aug 24, 2024
1 parent f0e06c4 commit 49c61d7
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/app_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use hyper::StatusCode;
use crate::{
app_state::AppState,
services::{
CreateReservationRequestService, GetOutboxService, ReservationDatabaseService,
GetOutboxService, ReservationDatabaseService, ReservationRequestService,
ReservationService, SendReservationMessageService, UserService,
},
};
Expand All @@ -30,7 +30,7 @@ pub async fn create_reservation<DB, MessageService, ReservationRequest>(
where
DB: ReservationDatabaseService + Clone,
MessageService: SendReservationMessageService + GetOutboxService,
ReservationRequest: CreateReservationRequestService,
ReservationRequest: ReservationRequestService,
{
let mut db = state.db.lock().await;
let id = db.get_reservations().len() as u64 + 1;
Expand Down Expand Up @@ -92,7 +92,7 @@ mod tests {
use crate::{
database::MockDatabase,
drivers::MockMailer,
entities::{CreateReservation, Reservation},
entities::{Reservation, ReservationRequest},
messages::Email,
};
use axum::{
Expand All @@ -112,7 +112,7 @@ mod tests {
.route("/reservations", get(get_reservations))
.route(
"/reservations",
post(create_reservation::<MockDatabase, MockMailer<Email>, CreateReservation>),
post(create_reservation::<MockDatabase, MockMailer<Email>, ReservationRequest>),
)
.route("/reservations/:id", delete(delete_reservation))
.route("/mailer/outbox", get(get_outbox))
Expand Down
5 changes: 2 additions & 3 deletions src/entities/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
pub mod create_reservation;
pub mod reservation;
pub mod reservation_request;
pub mod user;

#[allow(unused)]
pub use create_reservation::CreateReservation;
pub use reservation::Reservation;
pub use reservation_request::ReservationRequest;
pub use user::User;
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use serde::Deserialize;

use crate::services::CreateReservationRequestService;
use crate::services::ReservationRequestService;

#[derive(Deserialize)]
pub struct CreateReservation {
pub struct ReservationRequest {
name: String,
email: String,
room: String,
}

impl CreateReservationRequestService for CreateReservation {
impl ReservationRequestService for ReservationRequest {
fn name(&self) -> String {
self.name.clone()
}
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use app_handlers::{create_reservation, delete_reservation, get_outbox, get_reser
use app_state::AppState;
use database::MockDatabase;
use drivers::MockMailer;
use entities::CreateReservation;
use entities::ReservationRequest;
use messages::Email;

use axum::{
Expand All @@ -28,7 +28,7 @@ async fn main() {
.route("/reservations", get(get_reservations))
.route(
"/reservations",
post(create_reservation::<MockDatabase, MockMailer<Email>, CreateReservation>),
post(create_reservation::<MockDatabase, MockMailer<Email>, ReservationRequest>),
)
.route("/reservations/:id", delete(delete_reservation))
.route("/mailer/outbox", get(get_outbox))
Expand Down
4 changes: 2 additions & 2 deletions src/services/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
pub mod create_reservation_request_service;
pub mod database_service;
pub mod message_service;
pub mod reservation_message_service;
pub mod reservation_request_service;
pub mod reservation_service;
pub mod user_service;

pub use self::message_service::{GetOutboxService, SendReservationMessageService};
pub use self::reservation_message_service::ReservationMessageService;
pub use create_reservation_request_service::CreateReservationRequestService;
pub use database_service::ReservationDatabaseService;
pub use reservation_request_service::ReservationRequestService;
pub use reservation_service::ReservationService;
pub use user_service::UserService;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub trait CreateReservationRequestService {
pub trait ReservationRequestService {
fn name(&self) -> String;
fn email(&self) -> String;
fn room(&self) -> String;
Expand Down

0 comments on commit 49c61d7

Please sign in to comment.