settings/inspect/utils/
enums.rs1use crate::handler::base::{Error, Response};
6
7#[derive(Debug)]
8pub(crate) enum ResponseType {
12 OkSome,
13 OkNone,
14 UnimplementedRequest,
15 StorageFailure,
16 InitFailure,
17 RestoreFailure,
18 InvalidArgument,
19 IncompatibleArguments,
20 ExternalFailure,
21 UnhandledType,
22 DeliveryError,
23 UnexpectedError,
24 UndeliverableError,
25 UnsupportedError,
26 CommunicationError,
27 IrrecoverableError,
28 TimeoutError,
29}
30
31impl From<Error> for ResponseType {
32 fn from(error: Error) -> Self {
33 match error {
34 Error::UnimplementedRequest(_setting_type, _request) => {
35 ResponseType::UnimplementedRequest
36 }
37 Error::StorageFailure(_setting_type) => ResponseType::StorageFailure,
38 Error::InitFailure(_cause) => ResponseType::InitFailure,
39 Error::RestoreFailure(_cause) => ResponseType::RestoreFailure,
40 Error::InvalidArgument(_setting_type, _argument, _value) => {
41 ResponseType::InvalidArgument
42 }
43 Error::IncompatibleArguments { .. } => ResponseType::IncompatibleArguments,
44 Error::ExternalFailure(_setting_type, _dependency, _request, _error) => {
45 ResponseType::ExternalFailure
46 }
47 Error::UnhandledType(_setting_type) => ResponseType::UnhandledType,
48 Error::DeliveryError(_setting_type_1, _setting_type_2) => ResponseType::DeliveryError,
49 Error::UnexpectedError(_error) => ResponseType::UnexpectedError,
50 Error::UndeliverableError(_setting_type, _request) => ResponseType::UndeliverableError,
51 Error::UnsupportedError(_setting_type) => ResponseType::UnsupportedError,
52 Error::CommunicationError => ResponseType::CommunicationError,
53 Error::IrrecoverableError => ResponseType::IrrecoverableError,
54 Error::TimeoutError => ResponseType::TimeoutError,
55 }
56 }
57}
58
59impl From<Response> for ResponseType {
60 fn from(response: Response) -> Self {
61 match response {
62 Ok(Some(_)) => ResponseType::OkSome,
63 Ok(None) => ResponseType::OkNone,
64 Err(error) => error.into(),
65 }
66 }
67}