1
- use std:: error:: Error ;
2
-
3
- use crate :: error:: Fatal ;
4
- use crate :: error:: Infallible ;
5
1
use crate :: error:: NetworkError ;
6
2
use crate :: error:: RPCError ;
7
- use crate :: error:: RemoteError ;
8
3
use crate :: error:: ReplicationClosed ;
9
4
use crate :: error:: ReplicationError ;
10
5
use crate :: error:: Timeout ;
@@ -16,13 +11,8 @@ use crate::StorageError;
16
11
///
17
12
/// Thus this error includes storage error, network error, and remote error.
18
13
#[ derive( Debug , Clone , PartialEq , Eq , thiserror:: Error ) ]
19
- #[ cfg_attr(
20
- feature = "serde" ,
21
- derive( serde:: Serialize , serde:: Deserialize ) ,
22
- serde( bound( serialize = "E: serde::Serialize" ) ) ,
23
- serde( bound( deserialize = "E: for <'d> serde::Deserialize<'d>" ) )
24
- ) ]
25
- pub enum StreamingError < C : RaftTypeConfig , E : Error = Infallible > {
14
+ #[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
15
+ pub enum StreamingError < C : RaftTypeConfig > {
26
16
/// The replication stream is closed intentionally.
27
17
#[ error( transparent) ]
28
18
Closed ( #[ from] ReplicationClosed ) ,
@@ -42,24 +32,16 @@ pub enum StreamingError<C: RaftTypeConfig, E: Error = Infallible> {
42
32
/// Failed to send the RPC request and should retry immediately.
43
33
#[ error( transparent) ]
44
34
Network ( #[ from] NetworkError ) ,
45
-
46
- /// Remote node returns an error.
47
- #[ error( transparent) ]
48
- RemoteError ( #[ from] RemoteError < C , E > ) ,
49
35
}
50
36
51
- impl < C : RaftTypeConfig > From < StreamingError < C , Fatal < C > > > for ReplicationError < C > {
52
- fn from ( e : StreamingError < C , Fatal < C > > ) -> Self {
37
+ impl < C : RaftTypeConfig > From < StreamingError < C > > for ReplicationError < C > {
38
+ fn from ( e : StreamingError < C > ) -> Self {
53
39
match e {
54
40
StreamingError :: Closed ( e) => ReplicationError :: Closed ( e) ,
55
41
StreamingError :: StorageError ( e) => ReplicationError :: StorageError ( e) ,
56
42
StreamingError :: Timeout ( e) => ReplicationError :: RPCError ( RPCError :: Timeout ( e) ) ,
57
43
StreamingError :: Unreachable ( e) => ReplicationError :: RPCError ( RPCError :: Unreachable ( e) ) ,
58
44
StreamingError :: Network ( e) => ReplicationError :: RPCError ( RPCError :: Network ( e) ) ,
59
- StreamingError :: RemoteError ( e) => {
60
- // Fatal on remote error is considered as unreachable.
61
- ReplicationError :: RPCError ( RPCError :: Unreachable ( Unreachable :: new ( & e. source ) ) )
62
- }
63
45
}
64
46
}
65
47
}
@@ -74,22 +56,8 @@ impl<C: RaftTypeConfig> From<RPCError<C>> for StreamingError<C> {
74
56
unreachable ! ( "PayloadTooLarge should not be converted to StreamingError" )
75
57
}
76
58
RPCError :: Network ( e) => StreamingError :: Network ( e) ,
77
- RPCError :: RemoteError ( e) => StreamingError :: RemoteError ( e) ,
78
- }
79
- }
80
- }
81
-
82
- impl < C : RaftTypeConfig > From < StreamingError < C > > for ReplicationError < C > {
83
- fn from ( e : StreamingError < C > ) -> Self {
84
- #[ allow( unreachable_patterns) ]
85
- match e {
86
- StreamingError :: Closed ( e) => ReplicationError :: Closed ( e) ,
87
- StreamingError :: StorageError ( e) => ReplicationError :: StorageError ( e) ,
88
- StreamingError :: Timeout ( e) => ReplicationError :: RPCError ( RPCError :: Timeout ( e) ) ,
89
- StreamingError :: Unreachable ( e) => ReplicationError :: RPCError ( RPCError :: Unreachable ( e) ) ,
90
- StreamingError :: Network ( e) => ReplicationError :: RPCError ( RPCError :: Network ( e) ) ,
91
- StreamingError :: RemoteError ( _e) => {
92
- unreachable ! ( "Infallible error should not be converted to ReplicationError" )
59
+ RPCError :: RemoteError ( _e) => {
60
+ unreachable ! ( "Infallible error should not be produced at all" )
93
61
}
94
62
}
95
63
}
0 commit comments