@@ -90,64 +90,54 @@ impl std::error::Error for BuildSenderError {
90
90
/// `unwrap()`ing it is thus considered OK in Rust but you may achieve nicer message by displaying
91
91
/// it.
92
92
#[ derive( Debug ) ]
93
+ #[ cfg( feature = "v2" ) ]
93
94
pub struct CreateRequestError ( InternalCreateRequestError ) ;
94
95
95
96
#[ derive( Debug ) ]
97
+ #[ cfg( feature = "v2" ) ]
96
98
pub ( crate ) enum InternalCreateRequestError {
97
99
Url ( url:: ParseError ) ,
98
- #[ cfg( feature = "v2" ) ]
99
100
Hpke ( crate :: hpke:: HpkeError ) ,
100
- #[ cfg( feature = "v2" ) ]
101
101
OhttpEncapsulation ( crate :: ohttp:: OhttpEncapsulationError ) ,
102
- #[ cfg( feature = "v2" ) ]
103
102
ParseReceiverPubkey ( ParseReceiverPubkeyParamError ) ,
104
- #[ cfg( feature = "v2" ) ]
105
103
MissingOhttpConfig ,
106
- #[ cfg( feature = "v2" ) ]
107
104
Expired ( std:: time:: SystemTime ) ,
108
105
}
109
106
107
+ #[ cfg( feature = "v2" ) ]
110
108
impl fmt:: Display for CreateRequestError {
111
109
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
112
110
use InternalCreateRequestError :: * ;
113
111
114
112
match & self . 0 {
115
113
Url ( e) => write ! ( f, "cannot parse url: {:#?}" , e) ,
116
- #[ cfg( feature = "v2" ) ]
117
114
Hpke ( e) => write ! ( f, "v2 error: {}" , e) ,
118
- #[ cfg( feature = "v2" ) ]
119
115
OhttpEncapsulation ( e) => write ! ( f, "v2 error: {}" , e) ,
120
- #[ cfg( feature = "v2" ) ]
121
116
ParseReceiverPubkey ( e) => write ! ( f, "cannot parse receiver public key: {}" , e) ,
122
- #[ cfg( feature = "v2" ) ]
123
117
MissingOhttpConfig =>
124
118
write ! ( f, "no ohttp configuration with which to make a v2 request available" ) ,
125
- #[ cfg( feature = "v2" ) ]
126
119
Expired ( expiry) => write ! ( f, "session expired at {:?}" , expiry) ,
127
120
}
128
121
}
129
122
}
130
123
124
+ #[ cfg( feature = "v2" ) ]
131
125
impl std:: error:: Error for CreateRequestError {
132
126
fn source ( & self ) -> Option < & ( dyn std:: error:: Error + ' static ) > {
133
127
use InternalCreateRequestError :: * ;
134
128
135
129
match & self . 0 {
136
130
Url ( error) => Some ( error) ,
137
- #[ cfg( feature = "v2" ) ]
138
131
Hpke ( error) => Some ( error) ,
139
- #[ cfg( feature = "v2" ) ]
140
132
OhttpEncapsulation ( error) => Some ( error) ,
141
- #[ cfg( feature = "v2" ) ]
142
133
ParseReceiverPubkey ( error) => Some ( error) ,
143
- #[ cfg( feature = "v2" ) ]
144
134
MissingOhttpConfig => None ,
145
- #[ cfg( feature = "v2" ) ]
146
135
Expired ( _) => None ,
147
136
}
148
137
}
149
138
}
150
139
140
+ #[ cfg( feature = "v2" ) ]
151
141
impl From < InternalCreateRequestError > for CreateRequestError {
152
142
fn from ( value : InternalCreateRequestError ) -> Self { CreateRequestError ( value) }
153
143
}
0 commit comments