1
1
#[ cfg( not( target_arch = "wasm32" ) ) ]
2
2
use crate :: policies:: TransportPolicy ;
3
3
use crate :: policies:: { CustomHeadersInjectorPolicy , Policy , TelemetryPolicy } ;
4
- use crate :: { ClientOptions , Error , HttpClient , PipelineContext , Request , Response } ;
4
+ use crate :: { ClientOptions , Context , Error , HttpClient , Request , Response } ;
5
5
use std:: sync:: Arc ;
6
6
7
7
/// Execution pipeline.
@@ -32,18 +32,12 @@ use std::sync::Arc;
32
32
/// context. For example, in CosmosDB, the generic carries the operation-specific information used by
33
33
/// the authorization policy.
34
34
#[ derive( Debug , Clone ) ]
35
- pub struct Pipeline < C >
36
- where
37
- C : Send + Sync ,
38
- {
35
+ pub struct Pipeline {
39
36
http_client : Arc < dyn HttpClient > ,
40
- pipeline : Vec < Arc < dyn Policy < C > > > ,
37
+ pipeline : Vec < Arc < dyn Policy > > ,
41
38
}
42
39
43
- impl < C > Pipeline < C >
44
- where
45
- C : Send + Sync ,
46
- {
40
+ impl Pipeline {
47
41
/// Creates a new pipeline given the client library crate name and version,
48
42
/// alone with user-specified and client library-specified policies.
49
43
///
@@ -52,11 +46,11 @@ where
52
46
pub fn new (
53
47
crate_name : Option < & ' static str > ,
54
48
crate_version : Option < & ' static str > ,
55
- options : ClientOptions < C > ,
56
- per_call_policies : Vec < Arc < dyn Policy < C > > > ,
57
- per_retry_policies : Vec < Arc < dyn Policy < C > > > ,
49
+ options : ClientOptions ,
50
+ per_call_policies : Vec < Arc < dyn Policy > > ,
51
+ per_retry_policies : Vec < Arc < dyn Policy > > ,
58
52
) -> Self {
59
- let mut pipeline: Vec < Arc < dyn Policy < C > > > = Vec :: with_capacity (
53
+ let mut pipeline: Vec < Arc < dyn Policy > > = Vec :: with_capacity (
60
54
options. per_call_policies . len ( )
61
55
+ per_call_policies. len ( )
62
56
+ options. per_retry_policies . len ( )
83
77
#[ cfg( not( target_arch = "wasm32" ) ) ]
84
78
{
85
79
#[ allow( unused_mut) ]
86
- let mut policy: Arc < dyn Policy < _ > > =
80
+ let mut policy: Arc < dyn Policy > =
87
81
Arc :: new ( TransportPolicy :: new ( options. transport . clone ( ) ) ) ;
88
82
89
83
// This code replaces the default transport policy at runtime if these two conditions
@@ -132,23 +126,15 @@ where
132
126
self . http_client . as_ref ( )
133
127
}
134
128
135
- pub fn replace_policy (
136
- & mut self ,
137
- policy : Arc < dyn Policy < C > > ,
138
- position : usize ,
139
- ) -> Arc < dyn Policy < C > > {
129
+ pub fn replace_policy ( & mut self , policy : Arc < dyn Policy > , position : usize ) -> Arc < dyn Policy > {
140
130
std:: mem:: replace ( & mut self . pipeline [ position] , policy)
141
131
}
142
132
143
- pub fn policies ( & self ) -> & [ Arc < dyn Policy < C > > ] {
133
+ pub fn policies ( & self ) -> & [ Arc < dyn Policy > ] {
144
134
& self . pipeline
145
135
}
146
136
147
- pub async fn send (
148
- & self ,
149
- ctx : & mut PipelineContext < C > ,
150
- request : & mut Request ,
151
- ) -> Result < Response , Error > {
137
+ pub async fn send ( & self , ctx : & mut Context , request : & mut Request ) -> Result < Response , Error > {
152
138
self . pipeline [ 0 ]
153
139
. send ( ctx, request, & self . pipeline [ 1 ..] )
154
140
. await
0 commit comments