Skip to main content

Predicate

Enum Predicate 

Source
pub enum Predicate<In = Request<Bytes>, Err = ProximaError> {
    Always {
        _marker: PhantomData<fn(In) -> Err>,
    },
    Never {
        _marker: PhantomData<fn(In) -> Err>,
    },
    When {
        gate: When,
        calls: Arc<AtomicU64>,
        _marker: PhantomData<fn(In) -> Err>,
    },
    Unless {
        gate: When,
        calls: Arc<AtomicU64>,
        _marker: PhantomData<fn(In) -> Err>,
    },
}
Expand description

The config-expressible predicate set, generic over the payload In it passes through unchanged on admit and the Err it rejects with. Implements SendPipe/Pipe directly (In -> Result<In, Err>): Ok(input) on admit, Err::forbidden() on reject — the same payload FilterConfig’s RejectMode::Drop produces, since drop was always this crate’s default reject mode (FilterConfig::default). Defaults to the crate’s own HTTP types (Request<Bytes>, ProximaError) so a caller instantiates Predicate::<MyIn, MyErr> to gate their own payload without minting a type and without touching this one.

Variants§

§

Always

Fields

§_marker: PhantomData<fn(In) -> Err>
§

Never

Fields

§_marker: PhantomData<fn(In) -> Err>
§

When

Fields

§gate: When
§_marker: PhantomData<fn(In) -> Err>
§

Unless

Fields

§gate: When
§_marker: PhantomData<fn(In) -> Err>

Implementations§

Source§

impl<In, Err> Predicate<In, Err>

Source

pub fn always() -> Self

Source

pub fn never() -> Self

Source

pub fn when(gate: When) -> Self

Source

pub fn unless(gate: When) -> Self

Trait Implementations§

Source§

impl<In, Err> Clone for Predicate<In, Err>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<In, Err> Debug for Predicate<In, Err>

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, In, Err> Deserialize<'de> for Predicate<In, Err>

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<In, Err> PartialEq for Predicate<In, Err>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<In, Err> Pipe for Predicate<In, Err>
where In: 'static, Err: From<RejectMode> + Debug + 'static,

Source§

type In = In

Input the pipe consumes.
Source§

type Out = In

Output the pipe produces.
Source§

type Err = Err

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

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

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

impl<In, Err> SendPipe for Predicate<In, Err>
where In: Send + 'static, Err: From<RejectMode> + Debug + Send + 'static,

Source§

type In = In

Input the pipe consumes.
Source§

type Out = In

Output the pipe produces.
Source§

type Err = Err

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

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

Apply the pipe. The returned future IS Send.
Source§

impl<In, Err> Serialize for Predicate<In, Err>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<In, Err> UnpinPipe for Predicate<In, Err>
where In: 'static, Err: From<RejectMode> + Debug + 'static,

Source§

type In = In

Input the pipe consumes.
Source§

type Out = In

Output the pipe produces.
Source§

type Err = Err

Error the pipe can fail with.
Source§

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

Apply the pipe. The returned future IS Unpin — pollable in place.
Source§

impl<In, Err> UnpinSendPipe for Predicate<In, Err>
where In: Send + 'static, Err: From<RejectMode> + Debug + Send + 'static,

Source§

type In = In

Input the pipe consumes.
Source§

type Out = In

Output the pipe produces.
Source§

type Err = Err

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

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

Apply the pipe. The returned future is Send AND Unpin.

Auto Trait Implementations§

§

impl<In, Err> Freeze for Predicate<In, Err>
where PhantomData<fn(In) -> Err>: Freeze,

§

impl<In, Err> RefUnwindSafe for Predicate<In, Err>
where PhantomData<fn(In) -> Err>: RefUnwindSafe,

§

impl<In, Err> Send for Predicate<In, Err>
where PhantomData<fn(In) -> Err>: Send,

§

impl<In, Err> Sync for Predicate<In, Err>
where PhantomData<fn(In) -> Err>: Sync,

§

impl<In, Err> Unpin for Predicate<In, Err>
where PhantomData<fn(In) -> Err>: Unpin,

§

impl<In, Err> UnsafeUnpin for Predicate<In, Err>
where PhantomData<fn(In) -> Err>: UnsafeUnpin,

§

impl<In, Err> UnwindSafe for Predicate<In, Err>
where PhantomData<fn(In) -> Err>: 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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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<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<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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