File tree 4 files changed +10
-9
lines changed
4 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -228,7 +228,7 @@ impl ::serde::Serialize for SecretKey {
228
228
impl < ' de > :: serde:: Deserialize < ' de > for SecretKey {
229
229
fn deserialize < D : :: serde:: Deserializer < ' de > > ( d : D ) -> Result < Self , D :: Error > {
230
230
if d. is_human_readable ( ) {
231
- d. deserialize_str ( super :: serde_util:: HexVisitor :: new (
231
+ d. deserialize_str ( super :: serde_util:: FromStrVisitor :: new (
232
232
"a hex string representing 32 byte SecretKey"
233
233
) )
234
234
} else {
@@ -442,7 +442,7 @@ impl ::serde::Serialize for PublicKey {
442
442
impl < ' de > :: serde:: Deserialize < ' de > for PublicKey {
443
443
fn deserialize < D : :: serde:: Deserializer < ' de > > ( d : D ) -> Result < PublicKey , D :: Error > {
444
444
if d. is_human_readable ( ) {
445
- d. deserialize_str ( super :: serde_util:: HexVisitor :: new (
445
+ d. deserialize_str ( super :: serde_util:: FromStrVisitor :: new (
446
446
"an ASCII hex string representing a public key"
447
447
) )
448
448
} else {
Original file line number Diff line number Diff line change @@ -444,7 +444,7 @@ impl ::serde::Serialize for Signature {
444
444
impl < ' de > :: serde:: Deserialize < ' de > for Signature {
445
445
fn deserialize < D : :: serde:: Deserializer < ' de > > ( d : D ) -> Result < Self , D :: Error > {
446
446
if d. is_human_readable ( ) {
447
- d. deserialize_str ( serde_util:: HexVisitor :: new (
447
+ d. deserialize_str ( serde_util:: FromStrVisitor :: new (
448
448
"a hex string representing a DER encoded Signature"
449
449
) )
450
450
} else {
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ impl ::serde::Serialize for Signature {
34
34
impl < ' de > :: serde:: Deserialize < ' de > for Signature {
35
35
fn deserialize < D : :: serde:: Deserializer < ' de > > ( d : D ) -> Result < Self , D :: Error > {
36
36
if d. is_human_readable ( ) {
37
- d. deserialize_str ( super :: serde_util:: HexVisitor :: new (
37
+ d. deserialize_str ( super :: serde_util:: FromStrVisitor :: new (
38
38
"a hex string representing 64 byte schnorr signature"
39
39
) )
40
40
} else {
@@ -417,7 +417,7 @@ impl ::serde::Serialize for PublicKey {
417
417
impl < ' de > :: serde:: Deserialize < ' de > for PublicKey {
418
418
fn deserialize < D : :: serde:: Deserializer < ' de > > ( d : D ) -> Result < Self , D :: Error > {
419
419
if d. is_human_readable ( ) {
420
- d. deserialize_str ( super :: serde_util:: HexVisitor :: new (
420
+ d. deserialize_str ( super :: serde_util:: FromStrVisitor :: new (
421
421
"a hex string representing 32 byte schnorr public key"
422
422
) )
423
423
} else {
Original file line number Diff line number Diff line change @@ -3,21 +3,22 @@ use core::marker::PhantomData;
3
3
use core:: str:: { self , FromStr } ;
4
4
use serde:: de;
5
5
6
- pub struct HexVisitor < T > {
6
+ /// A serde visitor that works for `T`s implementing `FromStr`.
7
+ pub struct FromStrVisitor < T > {
7
8
expectation : & ' static str ,
8
9
_pd : PhantomData < T > ,
9
10
}
10
11
11
- impl < T > HexVisitor < T > {
12
+ impl < T > FromStrVisitor < T > {
12
13
pub fn new ( expectation : & ' static str ) -> Self {
13
- HexVisitor {
14
+ FromStrVisitor {
14
15
expectation,
15
16
_pd : PhantomData ,
16
17
}
17
18
}
18
19
}
19
20
20
- impl < ' de , T > de:: Visitor < ' de > for HexVisitor < T >
21
+ impl < ' de , T > de:: Visitor < ' de > for FromStrVisitor < T >
21
22
where
22
23
T : FromStr ,
23
24
<T as FromStr >:: Err : fmt:: Display ,
You can’t perform that action at this time.
0 commit comments