File tree 1 file changed +12
-4
lines changed
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -31,14 +31,22 @@ impl ToSql<Text, Pg> for EndpointScope {
31
31
}
32
32
}
33
33
34
- impl FromSql < Text , Pg > for EndpointScope {
35
- fn from_sql ( bytes : Option < & [ u8 ] > ) -> deserialize:: Result < Self > {
36
- match not_none ! ( bytes) {
34
+ impl TryFrom < & [ u8 ] > for EndpointScope {
35
+ type Error = String ;
36
+
37
+ fn try_from ( bytes : & [ u8 ] ) -> Result < Self , Self :: Error > {
38
+ match bytes {
37
39
b"publish-new" => Ok ( EndpointScope :: PublishNew ) ,
38
40
b"publish-update" => Ok ( EndpointScope :: PublishUpdate ) ,
39
41
b"yank" => Ok ( EndpointScope :: Yank ) ,
40
42
b"change-owners" => Ok ( EndpointScope :: ChangeOwners ) ,
41
- _ => Err ( "Unrecognized enum variant" . into ( ) ) ,
43
+ _ => Err ( "Unrecognized enum variant" . to_string ( ) ) ,
42
44
}
43
45
}
44
46
}
47
+
48
+ impl FromSql < Text , Pg > for EndpointScope {
49
+ fn from_sql ( bytes : Option < & [ u8 ] > ) -> deserialize:: Result < Self > {
50
+ Ok ( EndpointScope :: try_from ( not_none ! ( bytes) ) ?)
51
+ }
52
+ }
You can’t perform that action at this time.
0 commit comments