pub trait MakeHeaderValueFactory<S, ReqBody, ResBody>:
    Send
    + Sync
    + 'static {
    type Maker: MakeHeaderValue<ResBody>;

    // Required method
    fn make_header_value_maker(
        &self,
        ctx: Context<S>,
        request: Request<ReqBody>,
    ) -> impl Future<Output = (Context<S>, Request<ReqBody>, Self::Maker)> + Send;
}
Expand description

Trait for preparing a maker (MakeHeaderValue) that will be used to actually create the HeaderValue when desired.

The reason why this is split in two parts for responses is because the context is consumed by the inner service producting the response to which the header (maybe) will be attached to. In order to not clone the entire Context and its State it is therefore better to let the implementer decide what state is to be cloned and which not.

E.g. for a static Header value one might not need any state or context at all, which would make it pretty wastefull if we would for such cases clone these stateful datastructures anyhow.

Most users will however not have to worry about this Trait or why it is there, as the trait is implemented already for functions, closures and HeaderValues.

Required Associated Types§

type Maker: MakeHeaderValue<ResBody>

Maker that can be produced by this Factory.

Required Methods§

fn make_header_value_maker( &self, ctx: Context<S>, request: Request<ReqBody>, ) -> impl Future<Output = (Context<S>, Request<ReqBody>, Self::Maker)> + Send

Try to create a header value from the request or response.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

§

impl<S, ReqBody, ResBody> MakeHeaderValueFactory<S, ReqBody, ResBody> for Option<HeaderValue>
where S: Clone + Send + Sync + 'static, ReqBody: Send + 'static, ResBody: Send + 'static,

§

type Maker = Option<HeaderValue>

§

fn make_header_value_maker( &self, ctx: Context<S>, req: Request<ReqBody>, ) -> impl Future<Output = (Context<S>, Request<ReqBody>, <Option<HeaderValue> as MakeHeaderValueFactory<S, ReqBody, ResBody>>::Maker)> + Send

Implementors§

§

impl<S, ReqBody, ResBody> MakeHeaderValueFactory<S, ReqBody, ResBody> for HeaderValue
where S: Clone + Send + Sync + 'static, ReqBody: Send + 'static, ResBody: Send + 'static,

§

impl<S, ReqBody, ResBody, A, F> MakeHeaderValueFactory<S, ReqBody, ResBody> for BoxMakeHeaderValueFactoryFn<F, A>
where A: Send + 'static, F: MakeHeaderValueFactoryFn<S, ReqBody, ResBody, A>,

§

type Maker = <F as MakeHeaderValueFactoryFn<S, ReqBody, ResBody, A>>::Maker