File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -32,18 +32,19 @@ where
32
32
D : Deserializer < ' de > ,
33
33
{
34
34
let channel_id = String :: deserialize ( deserializer) ?;
35
- let channel_id = validate_channel_id ( & channel_id) . map_err ( serde:: de:: Error :: custom) ?;
36
- <[ u8 ; 32 ] as FromHex >:: from_hex ( channel_id) . map_err ( serde:: de:: Error :: custom)
35
+ validate_channel_id ( & channel_id) . map_err ( serde:: de:: Error :: custom)
37
36
}
38
37
39
- fn validate_channel_id ( s : & str ) -> Result < & str , FromHexError > {
38
+ fn validate_channel_id ( s : & str ) -> Result < [ u8 ; 32 ] , FromHexError > {
40
39
match ( s. get ( 0 ..2 ) , s. get ( 2 ..) ) {
41
- ( Some ( prefix) , Some ( hex) ) => if hex. len ( ) != 64 || prefix != "0x" {
42
- Err ( FromHexError :: InvalidStringLength )
43
- } else {
44
- Ok ( hex)
45
- } ,
46
- _ => Err ( FromHexError :: InvalidStringLength )
40
+ ( Some ( prefix) , Some ( hex) ) => {
41
+ if hex. len ( ) != 64 || prefix != "0x" {
42
+ Err ( FromHexError :: InvalidStringLength )
43
+ } else {
44
+ Ok ( <[ u8 ; 32 ] as FromHex >:: from_hex ( s) ?)
45
+ }
46
+ }
47
+ _ => Err ( FromHexError :: InvalidStringLength ) ,
47
48
}
48
49
}
49
50
You can’t perform that action at this time.
0 commit comments