@@ -17,6 +17,9 @@ use serde::{
17
17
} ;
18
18
19
19
/// Configuration for outbound request concurrency.
20
+ ///
21
+ /// This can be set either to one of the below enum values or to a positive integer, which denotes
22
+ /// a fixed concurrency limit.
20
23
#[ derive( Clone , Copy , Debug , Derivative , Eq , PartialEq ) ]
21
24
pub enum Concurrency {
22
25
/// A fixed concurrency of 1.
@@ -48,28 +51,29 @@ impl Serialize for Concurrency {
48
51
49
52
impl Default for Concurrency {
50
53
fn default ( ) -> Self {
51
- Self :: None
54
+ Self :: Adaptive
52
55
}
53
56
}
54
57
55
58
impl Concurrency {
56
- pub const fn if_none ( self , other : Self ) -> Self {
59
+ const fn if_adaptive ( self , other : Self ) -> Self {
57
60
match self {
58
- Self :: None => other,
61
+ Self :: Adaptive => other,
59
62
_ => self ,
60
63
}
61
64
}
62
65
63
- pub const fn parse_concurrency ( & self , default : Self ) -> Option < usize > {
64
- match self . if_none ( default) {
65
- Concurrency :: None | Concurrency :: Adaptive => None ,
66
+ pub const fn parse_concurrency ( & self , other : Self ) -> Option < usize > {
67
+ match self . if_adaptive ( other) {
68
+ Concurrency :: None => Some ( 1 ) ,
69
+ Concurrency :: Adaptive => None ,
66
70
Concurrency :: Fixed ( limit) => Some ( limit) ,
67
71
}
68
72
}
69
73
}
70
74
71
- pub const fn concurrency_is_none ( concurrency : & Concurrency ) -> bool {
72
- matches ! ( concurrency, Concurrency :: None )
75
+ pub const fn concurrency_is_adaptive ( concurrency : & Concurrency ) -> bool {
76
+ matches ! ( concurrency, Concurrency :: Adaptive )
73
77
}
74
78
75
79
impl < ' de > Deserialize < ' de > for Concurrency {
@@ -93,7 +97,7 @@ impl<'de> Deserialize<'de> for Concurrency {
93
97
} else if value == "none" {
94
98
Ok ( Concurrency :: None )
95
99
} else {
96
- Err ( de:: Error :: unknown_variant ( value, & [ "adaptive" ] ) )
100
+ Err ( de:: Error :: unknown_variant ( value, & [ "adaptive" , "none" ] ) )
97
101
}
98
102
}
99
103
@@ -132,7 +136,12 @@ impl Configurable for Concurrency {
132
136
133
137
fn metadata ( ) -> Metadata {
134
138
let mut metadata = Metadata :: default ( ) ;
135
- metadata. set_description ( "Configuration for outbound request concurrency." ) ;
139
+ metadata. set_description (
140
+ r#"Configuration for outbound request concurrency.
141
+
142
+ This can be set either to one of the below enum values or to a positive integer, which denotes
143
+ a fixed concurrency limit."# ,
144
+ ) ;
136
145
metadata. add_custom_attribute ( CustomAttribute :: kv ( "docs::enum_tagging" , "external" ) ) ;
137
146
metadata
138
147
}
0 commit comments