1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
mod custom_headers_policy;
mod retry_policies;
mod telemetry_policy;
mod timeout_policy;
mod transport;
pub use custom_headers_policy::{CustomHeaders, CustomHeadersPolicy};
pub use retry_policies::*;
pub use telemetry_policy::*;
pub use timeout_policy::*;
pub use transport::*;
use crate::{Context, Request, Response};
use async_trait::async_trait;
use std::sync::Arc;
pub type PolicyResult = crate::error::Result<Response>;
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
pub trait Policy: Send + Sync + std::fmt::Debug {
async fn send(
&self,
ctx: &Context,
request: &mut Request,
next: &[Arc<dyn Policy>],
) -> PolicyResult;
}