@@ -17,6 +17,7 @@ use self::Error::{
17
17
Status ,
18
18
Timeout ,
19
19
Upgrade ,
20
+ Cancel ,
20
21
Io ,
21
22
TooLarge ,
22
23
Incomplete ,
@@ -47,6 +48,8 @@ pub enum Error {
47
48
Timeout ,
48
49
/// A protocol upgrade was encountered, but not yet supported in hyper.
49
50
Upgrade ,
51
+ /// A pending item was dropped before ever being processed.
52
+ Cancel ( Canceled ) ,
50
53
/// An `io::Error` that occurred while trying to read or write to a network stream.
51
54
Io ( IoError ) ,
52
55
/// Parsing a field as string failed
@@ -56,6 +59,45 @@ pub enum Error {
56
59
__Nonexhaustive( Void )
57
60
}
58
61
62
+ impl Error {
63
+ pub ( crate ) fn new_canceled ( ) -> Error {
64
+ Error :: Cancel ( Canceled {
65
+ _inner : ( ) ,
66
+ } )
67
+ }
68
+ }
69
+
70
+ /// A pending item was dropped before ever being processed.
71
+ ///
72
+ /// For example, a `Request` could be queued in the `Client`, *just*
73
+ /// as the related connection gets closed by the remote. In that case,
74
+ /// when the connection drops, the pending response future will be
75
+ /// fulfilled with this error, signaling the `Request` was never started.
76
+ pub struct Canceled {
77
+ // maybe in the future this contains an optional value of
78
+ // what was canceled?
79
+ _inner : ( ) ,
80
+ }
81
+
82
+ impl Canceled {
83
+ fn description ( & self ) -> & str {
84
+ "an operation was canceled internally before starting"
85
+ }
86
+ }
87
+
88
+ impl fmt:: Debug for Canceled {
89
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
90
+ f. debug_struct ( "Canceled" )
91
+ . finish ( )
92
+ }
93
+ }
94
+
95
+ impl fmt:: Display for Canceled {
96
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
97
+ f. pad ( self . description ( ) )
98
+ }
99
+ }
100
+
59
101
#[ doc( hidden) ]
60
102
pub struct Void ( ( ) ) ;
61
103
@@ -87,6 +129,7 @@ impl StdError for Error {
87
129
Incomplete => "message is incomplete" ,
88
130
Timeout => "timeout" ,
89
131
Upgrade => "unsupported protocol upgrade" ,
132
+ Cancel ( ref e) => e. description ( ) ,
90
133
Uri ( ref e) => e. description ( ) ,
91
134
Io ( ref e) => e. description ( ) ,
92
135
Utf8 ( ref e) => e. description ( ) ,
@@ -143,6 +186,11 @@ impl From<httparse::Error> for Error {
143
186
}
144
187
}
145
188
189
+ #[ doc( hidden) ]
190
+ trait AssertSendSync : Send + Sync + ' static { }
191
+ #[ doc( hidden) ]
192
+ impl AssertSendSync for Error { }
193
+
146
194
#[ cfg( test) ]
147
195
mod tests {
148
196
use std:: error:: Error as StdError ;
0 commit comments