From d0e1e2cf469d2a0e2f4395c4b37d3b266e3109a8 Mon Sep 17 00:00:00 2001 From: PARK BYUNG JUN Date: Thu, 4 Aug 2022 09:13:23 +0000 Subject: [PATCH] from i32 is added --- src/protobuf/rpc.rs | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/src/protobuf/rpc.rs b/src/protobuf/rpc.rs index 83c69d3..172d4cf 100644 --- a/src/protobuf/rpc.rs +++ b/src/protobuf/rpc.rs @@ -35,14 +35,33 @@ pub struct InvalidParamsDetail { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum InvalidParamsType { - DateTime = 0, - Decimal = 1, - EqualsTo = 2, - Float = 3, - Integer = 4, - Range = 5, - RegEx = 6, - Required = 7, - StringLength = 8, - Url = 9, + None = 0, + DateTime = 1, + Decimal = 2, + EqualsTo = 3, + Float = 4, + Integer = 5, + Range = 6, + RegEx = 7, + Required = 8, + StringLength = 9, + Url = 10, +} + +impl From for InvalidParamsType { + fn from(s: i32) -> Self { + match s { + s if s == InvalidParamsType::DateTime as i32 => InvalidParamsType::DateTime, + s if s == InvalidParamsType::Decimal as i32 => InvalidParamsType::Decimal, + s if s == InvalidParamsType::EqualsTo as i32 => InvalidParamsType::EqualsTo, + s if s == InvalidParamsType::Float as i32 => InvalidParamsType::Float, + s if s == InvalidParamsType::Integer as i32 => InvalidParamsType::Integer, + s if s == InvalidParamsType::Range as i32 => InvalidParamsType::Range, + s if s == InvalidParamsType::RegEx as i32 => InvalidParamsType::RegEx, + s if s == InvalidParamsType::Required as i32 => InvalidParamsType::Required, + s if s == InvalidParamsType::StringLength as i32 => InvalidParamsType::StringLength, + s if s == InvalidParamsType::Url as i32 => InvalidParamsType::Url, + _ => InvalidParamsType::None, + } + } }