1mod custom_headers_policy;
2mod retry_policies;
3mod telemetry_policy;
4mod timeout_policy;
5mod transport;
67pub use custom_headers_policy::{CustomHeaders, CustomHeadersPolicy};
8pub use retry_policies::*;
9pub use telemetry_policy::*;
10pub use timeout_policy::*;
11pub use transport::*;
1213use crate::{Context, Request, Response};
14use async_trait::async_trait;
15use std::sync::Arc;
1617/// A specialized `Result` type for policies.
18pub type PolicyResult = crate::error::Result<Response>;
19// pub type PolicyResult = Result<Response, Box<dyn Error + Send + Sync>>;
2021/// A pipeline policy.
22///
23/// Policies are expected to modify the request and then call the following policy.
24/// Policies can then inspect the response, potentially signaling failure.
25/// The only runtime enforced check is that the last policy must be a Transport policy. It's up to
26/// the implementer to call the following policy.
27/// The `C` generic represents the *contents* of the AuthorizationPolicy specific of this pipeline.
28#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
29#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
30pub trait Policy: Send + Sync + std::fmt::Debug {
31async fn send(
32&self,
33 ctx: &Context,
34 request: &mut Request,
35 next: &[Arc<dyn Policy>],
36 ) -> PolicyResult;
37}