From 9dcb9e8651c2d2cde8854277c9dcb96a4f1af7b9 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Mon, 3 Apr 2023 03:01:20 +0000 Subject: refactor(handler): move traits --- src/handler.rs | 44 ++++++++------------------------------------ 1 file changed, 8 insertions(+), 36 deletions(-) (limited to 'src/handler.rs') diff --git a/src/handler.rs b/src/handler.rs index 88dafc8..63c353c 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -16,40 +16,12 @@ // Copyright (C) 2022-2022 Fuwn // SPDX-License-Identifier: GPL-3.0-only -use crate::{ - response::Response, - returnable, - returnable::{CallbackContext, RouteContext}, +mod hooks; +mod partial; +mod response; + +pub use self::{ + hooks::{PostRouteCallback, PreRouteCallback}, + partial::Partial, + response::{ErrorResponse, RouteResponse}, }; - -pub trait RouteResponse: - FnMut(RouteContext<'_>) -> Response + Send + Sync -{ -} - -impl RouteResponse for T where T: FnMut(RouteContext<'_>) -> Response + Send + Sync -{} - -pub trait ErrorResponse: - FnMut(returnable::ErrorContext<'_>) -> Response + Send + Sync -{ -} - -impl ErrorResponse for T where T: FnMut(returnable::ErrorContext<'_>) -> Response + Send + Sync -{} - -pub trait Callback: FnMut(CallbackContext<'_>) + Send + Sync {} - -impl Callback for T where T: FnMut(CallbackContext<'_>) + Send + Sync {} - -pub trait CleanupCallback: - FnMut(CallbackContext<'_>, &mut Response) + Send + Sync -{ -} - -impl CleanupCallback for T where T: FnMut(CallbackContext<'_>, &mut Response) + Send + Sync -{} - -pub trait Partial: FnMut(RouteContext<'_>) -> String + Send + Sync {} - -impl Partial for T where T: FnMut(RouteContext<'_>) -> String + Send + Sync {} -- cgit v1.2.3