From 57831dceb0665243e3f94434698331fbd8396acb Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 17 Feb 2016 19:17:51 +0100 Subject: [PATCH] Add HookErrorKind enums for Pre and Post errors --- libimagstore/src/hook.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/libimagstore/src/hook.rs b/libimagstore/src/hook.rs index 1280000d..2aeecd69 100644 --- a/libimagstore/src/hook.rs +++ b/libimagstore/src/hook.rs @@ -94,15 +94,39 @@ pub mod error { use std::fmt::Error as FmtError; use std::clone::Clone; use std::fmt::{Display, Formatter}; + use std::convert::Into; /** * Kind of error */ - #[derive(Clone, Copy, Debug, PartialEq)] + #[derive(Clone, Copy, Debug)] pub enum HookErrorKind { + Pre(PreHookErrorKind), + Post(PostHookErrorKind) + } + + #[derive(Clone, Copy, Debug, Eq, PartialEq)] + pub enum PreHookErrorKind { // ... } + impl Into for PreHookErrorKind { + fn into(self) -> HookErrorKind { + HookErrorKind::Pre(self) + } + } + + #[derive(Clone, Copy, Debug, Eq, PartialEq)] + pub enum PostHookErrorKind { + // ... + } + + impl Into for PostHookErrorKind { + fn into(self) -> HookErrorKind { + HookErrorKind::Post(self) + } + } + fn hook_error_type_as_str(e: &HookErrorKind) -> &'static str { match e { _ => "",