pub enum HookType {
TaskPanic(Option<isize>, ServerHookHandlerFactory),
RequestError(Option<isize>, ServerHookHandlerFactory),
RequestMiddleware(Option<isize>, ServerHookHandlerFactory),
Route(&'static str, ServerHookHandlerFactory),
ResponseMiddleware(Option<isize>, ServerHookHandlerFactory),
}Expand description
Represents different types of hooks in the server lifecycle.
Each variant corresponds to a specific hook that can be registered
and triggered at different stages of request handling or server events.
Hooks with an Option<isize> allow specifying a priority order; None indicates
the default order (0 or unspecified).
Variants§
TaskPanic(Option<isize>, ServerHookHandlerFactory)
Hook triggered when a task panic occurs during request processing.
Option<isize>- Optional execution priority. Higher values execute first.ServerHookHandlerFactory- Factory function creating the panic handler.
RequestError(Option<isize>, ServerHookHandlerFactory)
Hook triggered when a request error occurs during HTTP request processing.
Option<isize>- Optional execution priority. Higher values execute first.ServerHookHandlerFactory- Factory function creating the error handler.
RequestMiddleware(Option<isize>, ServerHookHandlerFactory)
Hook executed before a request reaches its designated route handler.
Option<isize>- Optional execution priority. Higher values execute first.ServerHookHandlerFactory- Factory function creating the middleware handler.
Route(&'static str, ServerHookHandlerFactory)
Hook representing a route handler for a specific path.
&'static str- The route path pattern handled by this hook.ServerHookHandlerFactory- Factory function creating the route handler.
ResponseMiddleware(Option<isize>, ServerHookHandlerFactory)
Hook executed after a route handler but before the response is sent.
Option<isize>- Optional execution priority. Higher values execute first.ServerHookHandlerFactory- Factory function creating the middleware handler.
Implementations§
Source§impl HookType
Implementation block for HookType.
impl HookType
Implementation block for HookType.
This block defines utility methods associated with the HookType enum.
These methods provide additional functionality for working with hooks,
such as extracting the execution order (priority) used in duplicate checks.
Sourcepub fn try_get_order(&self) -> Option<isize>
pub fn try_get_order(&self) -> Option<isize>
Returns the optional execution priority (order) of a hook.
Hooks that carry an order indicate their execution priority.
Hooks without an order are considered unordered and are ignored in duplicate checks.
§Returns
Option<isize>-Some(order)if the hook defines a priority, otherwiseNone.
pub fn try_get_hook(&self) -> Option<ServerHookHandlerFactory>
Trait Implementations§
Source§impl Hash for HookType
Implements the Hash trait for HookType.
impl Hash for HookType
Implements the Hash trait for HookType.
This allows HookType to be used as a key in hash-based collections.
Function pointers are hashed using their addresses.
Source§impl PartialEq for HookType
Implements the PartialEq trait for HookType.
impl PartialEq for HookType
Implements the PartialEq trait for HookType.
This allows for comparing two HookType instances for equality.
Function pointers are compared using std::ptr::fn_addr_eq for reliable comparison.
impl Collect for HookType
impl Copy for HookType
impl Eq for HookType
Implements the Eq trait for HookType.
This indicates that HookType has a total equality relation.