@@ -86,9 +86,7 @@ impl std::error::Error for BuildSenderError {
86
86
/// This is currently opaque type because we aren't sure which variants will stay.
87
87
/// You can only display it.
88
88
#[ derive( Debug ) ]
89
- pub struct ValidationError {
90
- internal : InternalValidationError ,
91
- }
89
+ pub struct ValidationError ( InternalValidationError ) ;
92
90
93
91
#[ derive( Debug ) ]
94
92
pub ( crate ) enum InternalValidationError {
@@ -100,24 +98,22 @@ pub(crate) enum InternalValidationError {
100
98
}
101
99
102
100
impl From < InternalValidationError > for ValidationError {
103
- fn from ( value : InternalValidationError ) -> Self { ValidationError { internal : value } }
101
+ fn from ( value : InternalValidationError ) -> Self { ValidationError ( value) }
104
102
}
105
103
106
104
impl From < crate :: psbt:: AddressTypeError > for ValidationError {
107
105
fn from ( value : crate :: psbt:: AddressTypeError ) -> Self {
108
- ValidationError {
109
- internal : InternalValidationError :: Proposal ( InternalProposalError :: InvalidAddressType (
110
- value,
111
- ) ) ,
112
- }
106
+ ValidationError ( InternalValidationError :: Proposal (
107
+ InternalProposalError :: InvalidAddressType ( value) ,
108
+ ) )
113
109
}
114
110
}
115
111
116
112
impl fmt:: Display for ValidationError {
117
113
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
118
114
use InternalValidationError :: * ;
119
115
120
- match & self . internal {
116
+ match & self . 0 {
121
117
Parse => write ! ( f, "couldn't decode as PSBT or JSON" , ) ,
122
118
Io ( e) => write ! ( f, "couldn't read PSBT: {}" , e) ,
123
119
Proposal ( e) => write ! ( f, "proposal PSBT error: {}" , e) ,
@@ -131,7 +127,7 @@ impl std::error::Error for ValidationError {
131
127
fn source ( & self ) -> Option < & ( dyn std:: error:: Error + ' static ) > {
132
128
use InternalValidationError :: * ;
133
129
134
- match & self . internal {
130
+ match & self . 0 {
135
131
Parse => None ,
136
132
Io ( error) => Some ( error) ,
137
133
Proposal ( e) => Some ( e) ,
@@ -329,16 +325,12 @@ impl From<WellKnownError> for ResponseError {
329
325
}
330
326
331
327
impl From < InternalValidationError > for ResponseError {
332
- fn from ( value : InternalValidationError ) -> Self {
333
- Self :: Validation ( ValidationError { internal : value } )
334
- }
328
+ fn from ( value : InternalValidationError ) -> Self { Self :: Validation ( ValidationError ( value) ) }
335
329
}
336
330
337
331
impl From < InternalProposalError > for ResponseError {
338
332
fn from ( value : InternalProposalError ) -> Self {
339
- ResponseError :: Validation ( ValidationError {
340
- internal : InternalValidationError :: Proposal ( value) ,
341
- } )
333
+ ResponseError :: Validation ( ValidationError ( InternalValidationError :: Proposal ( value) ) )
342
334
}
343
335
}
344
336
0 commit comments