From 7bf527b34d5a589d9b8dd5722c9f3ff6c0d5b9e7 Mon Sep 17 00:00:00 2001 From: Rudi Floren Date: Thu, 4 Jan 2024 19:56:01 +0100 Subject: [PATCH] Add is_persistent to ResultCode (#32) This is helpful when EPP requests are executed in a loop, and you want to know if the error result will persist for additional requests with similar but different arguments. --- src/response.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/response.rs b/src/response.rs index fb6d97c..9176082 100644 --- a/src/response.rs +++ b/src/response.rs @@ -135,6 +135,31 @@ impl ResultCode { | CommandCompletedSuccessfullyEndingSession ) } + + /// Returns true if this error is likely to persist across similar requests inside the same + /// connection or session. + /// + /// The same command with different arguments might succeed in some cases. + pub fn is_persistent(&self) -> bool { + use ResultCode::*; + match self { + // The same command with different arguments will result in the same error + UnknownCommand + | CommandSyntaxError + | RequiredParameterMissing + | ParameterValueRangeError + | ParameterValueSyntaxError + | UnimplementedProtocolVersion + | UnimplementedCommand + | UnimplementedOption + | UnimplementedExtension => true, + // The connection is in an unhealthy state + CommandFailedServerClosingConnection + | AuthenticationErrorServerClosingConnection + | SessionLimitExceededServerClosingConnection => true, + _ => false, + } + } } impl<'xml> FromXml<'xml> for ResultCode {