Skip to main content

Transform

Struct Transform 

Source
pub struct Transform<Inner = PipeHandle, InOp = RequestOp, OutOp = ResponseOp> {
    pub inner: Inner,
    /* private fields */
}
Expand description

Request/response transformation middleware. Generic over the inner pipe AND the op types; the std default type parameters (the HTTP RequestOp / ResponseOp, which carry regex::Regex) keep all existing call sites unchanged. Under no_std+alloc the HTTP op types are absent, so the defaults fall back to (); callers name their own op types explicitly.

Fields§

§inner: Inner

Implementations§

Source§

impl<Inner, InOp, OutOp> Transform<Inner, InOp, OutOp>

Source

pub fn new(inner: Inner) -> Self

Source

pub fn with_request_op(self, op: InOp) -> Self

Source

pub fn with_response_op(self, op: OutOp) -> Self

Source§

impl Transform<PipeHandle>

Source

pub fn from_spec(inner: PipeHandle, value: &Value) -> Result<Self, ProximaError>

Trait Implementations§

Source§

impl<InOp, OutOp> Pipe for Transform<ThreadLocalPipeHandle, InOp, OutOp>
where Request<Bytes>: ApplyOps<InOp>, Response<Bytes>: ApplyOps<OutOp>, InOp: Clone + Send + Sync + 'static, OutOp: Clone + Send + Sync + 'static,

Source§

type In = Request<Bytes>

Input the pipe consumes.
Source§

type Out = Response<Bytes>

Output the pipe produces.
Source§

type Err = ProximaError

Error the pipe can fail with. Debug + 'static; Send is added only on the cross-core SendPipe form.
Source§

fn call( &self, input: Request<Bytes>, ) -> impl Future<Output = Result<Response<Bytes>, ProximaError>>

Apply the pipe. The returned future is NOT required to be Send.
Source§

impl<Inner, InOp, OutOp> SendPipe for Transform<Inner, InOp, OutOp>
where Inner: SendPipe + Clone, Inner::In: ApplyOps<InOp> + Send, Inner::Out: ApplyOps<OutOp>, Inner::Err: Send, InOp: Clone + Send + Sync + 'static, OutOp: Clone + Send + Sync + 'static,

Source§

type In = <Inner as SendPipe>::In

Input the pipe consumes.
Source§

type Out = <Inner as SendPipe>::Out

Output the pipe produces.
Source§

type Err = <Inner as SendPipe>::Err

Error the pipe can fail with — Send here so it can cross cores.
Source§

fn call( &self, input: Inner::In, ) -> impl Future<Output = Result<Inner::Out, Inner::Err>> + Send

Apply the pipe. The returned future IS Send.

Auto Trait Implementations§

§

impl<Inner, InOp, OutOp> Freeze for Transform<Inner, InOp, OutOp>
where Inner: Freeze, Vec<InOp>: Freeze, Vec<OutOp>: Freeze,

§

impl<Inner, InOp, OutOp> RefUnwindSafe for Transform<Inner, InOp, OutOp>
where Inner: RefUnwindSafe, Vec<InOp>: RefUnwindSafe, Vec<OutOp>: RefUnwindSafe,

§

impl<Inner, InOp, OutOp> Send for Transform<Inner, InOp, OutOp>
where Inner: Send, Vec<InOp>: Send, Vec<OutOp>: Send,

§

impl<Inner, InOp, OutOp> Sync for Transform<Inner, InOp, OutOp>
where Inner: Sync, Vec<InOp>: Sync, Vec<OutOp>: Sync,

§

impl<Inner, InOp, OutOp> Unpin for Transform<Inner, InOp, OutOp>
where Inner: Unpin, Vec<InOp>: Unpin, Vec<OutOp>: Unpin,

§

impl<Inner, InOp, OutOp> UnsafeUnpin for Transform<Inner, InOp, OutOp>
where Inner: UnsafeUnpin, Vec<InOp>: UnsafeUnpin, Vec<OutOp>: UnsafeUnpin,

§

impl<Inner, InOp, OutOp> UnwindSafe for Transform<Inner, InOp, OutOp>
where Inner: UnwindSafe, Vec<InOp>: UnwindSafe, Vec<OutOp>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<P> DynPipe<<P as Pipe>::In, <P as Pipe>::Out> for P
where P: Pipe, ProximaError: From<<P as Pipe>::Err>,

Source§

fn call_dyn( &self, input: <P as Pipe>::In, ) -> Pin<Box<dyn Future<Output = Result<<P as Pipe>::Out, ProximaError>> + '_>>

Erased dispatch — boxes the inner pipe’s future and converts its error into ProximaError.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<Implementor> Handler for Implementor
where Implementor: SendPipe<In = Request<Bytes>, Out = Response<Bytes>, Err = ProximaError>,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P> PipeExt for P
where P: Pipe,

Source§

fn and_then<Next>(self, next: Next) -> AndThen<Self, Next>
where Next: Pipe<In = Self::Out>, Next::Err: From<Self::Err>,

self.and_then(next) is AndThen::new(self, next) — reads left-to-right at the call site.
Source§

fn filter<Pred>(self, predicate: Pred) -> AndThen<Pred, Self>
where Pred: Pipe<Out = Self::In>, Self::Err: From<Pred::Err>,

Gate self behind predicate.
Source§

fn fanout(self, other: Self) -> FanOut<Self, AllOrNothing>
where Self: Clone, Self::In: Clone,

Broadcast to self and other, all-or-nothing.
Source§

fn fanin<Strategy>( self, other: Self, strategy: Strategy, ) -> FanIn<Self, Strategy, 2>
where Self: UnpinPipe<In = (), Err = Exhausted> + DropSafe, Strategy: FanInStrategy,

Merge self and other into a two-source FanIn. FanIn sources are UnpinPipe-shaped (In = (), Err = Exhausted), hence the extra bound.
Source§

impl<P> SendDynPipe<<P as SendPipe>::In, <P as SendPipe>::Out> for P
where P: SendPipe, <P as SendPipe>::In: Send, ProximaError: From<<P as SendPipe>::Err>,

Source§

fn call_dyn( &self, input: <P as SendPipe>::In, ) -> Pin<Box<dyn Future<Output = Result<<P as SendPipe>::Out, ProximaError>> + Send + '_>>

Erased dispatch — boxes the inner pipe’s Send future and converts its error into ProximaError.
Source§

impl<Implementor> SourcePipe for Implementor
where Implementor: SendPipe<In = Signal, Out = (), Err = ProximaError>,

Source§

impl<Implementor> ThreadLocalHandler for Implementor
where Implementor: Pipe<In = Request<Bytes>, Out = Response<Bytes>, Err = ProximaError>,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more