File tree Expand file tree Collapse file tree 3 files changed +31
-4
lines changed Expand file tree Collapse file tree 3 files changed +31
-4
lines changed Original file line number Diff line number Diff line change 1
- 0.3.2
1
+ 0.4.0
Original file line number Diff line number Diff line change @@ -78,8 +78,35 @@ impl<'de> serde::Deserialize<'de> for Keypath {
78
78
where
79
79
D : serde:: Deserializer < ' de > ,
80
80
{
81
- let s = String :: deserialize ( deserializer) ?;
82
- s. as_str ( ) . try_into ( ) . map_err ( serde:: de:: Error :: custom)
81
+ struct KeypathVisitor ;
82
+
83
+ impl < ' de > serde:: de:: Visitor < ' de > for KeypathVisitor {
84
+ type Value = Keypath ;
85
+
86
+ fn expecting ( & self , formatter : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
87
+ formatter. write_str ( "a string or a number sequence" )
88
+ }
89
+
90
+ fn visit_str < E > ( self , value : & str ) -> Result < Self :: Value , E >
91
+ where
92
+ E : serde:: de:: Error ,
93
+ {
94
+ value. try_into ( ) . map_err ( serde:: de:: Error :: custom)
95
+ }
96
+
97
+ fn visit_seq < A > ( self , mut seq : A ) -> Result < Self :: Value , A :: Error >
98
+ where
99
+ A : serde:: de:: SeqAccess < ' de > ,
100
+ {
101
+ let mut vec = Vec :: < u32 > :: new ( ) ;
102
+ while let Some ( elem) = seq. next_element ( ) ? {
103
+ vec. push ( elem) ;
104
+ }
105
+ Ok ( Keypath ( vec) )
106
+ }
107
+ }
108
+
109
+ deserializer. deserialize_any ( KeypathVisitor )
83
110
}
84
111
}
85
112
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ type Product = 'unknown' | 'bitbox02-multi' | 'bitbox02-btconly';
15
15
type BtcCoin = 'btc' | 'tbtc' | 'ltc' | 'tltc';
16
16
type BtcFormatUnit = 'default' | 'sat';
17
17
type XPubType = 'tpub' | 'xpub' | 'ypub' | 'zpub' | 'vpub' | 'upub' | 'Vpub' | 'Zpub' | 'Upub' | 'Ypub';
18
- type Keypath = string;
18
+ type Keypath = string | number[] ;
19
19
type XPub = string;
20
20
type DeviceInfo = {
21
21
name: string;
You can’t perform that action at this time.
0 commit comments