Trait finchers::Endpoint
[−]
[src]
pub trait Endpoint { type Item; type Error; type Future: Future<Item = Self::Item, Error = Self::Error>; fn apply(self, ctx: &mut Context) -> EndpointResult<Self::Future>; fn join<E>(self, e: E) -> (Self, E)
where
Self: Sized,
E: Endpoint<Error = Self::Error>, { ... } fn join3<E1, E2>(self, e1: E1, e2: E2) -> (Self, E1, E2)
where
Self: Sized,
E1: Endpoint<Error = Self::Error>,
E2: Endpoint<Error = Self::Error>, { ... } fn join4<E1, E2, E3>(self, e1: E1, e2: E2, e3: E3) -> (Self, E1, E2, E3)
where
Self: Sized,
E1: Endpoint<Error = Self::Error>,
E2: Endpoint<Error = Self::Error>,
E3: Endpoint<Error = Self::Error>, { ... } fn join5<E1, E2, E3, E4>(
self,
e1: E1,
e2: E2,
e3: E3,
e4: E4
) -> (Self, E1, E2, E3, E4)
where
Self: Sized,
E1: Endpoint<Error = Self::Error>,
E2: Endpoint<Error = Self::Error>,
E3: Endpoint<Error = Self::Error>,
E4: Endpoint<Error = Self::Error>, { ... } fn with<E>(self, e: E) -> With<Self, E>
where
Self: Sized,
E: Endpoint, { ... } fn skip<E>(self, e: E) -> Skip<Self, E>
where
Self: Sized,
E: Endpoint, { ... } fn or<E>(self, e: E) -> Or<Self, E>
where
Self: Sized,
E: Endpoint<Item = Self::Item, Error = Self::Error>, { ... } fn map<F, U>(self, f: F) -> Map<Self, F>
where
Self: Sized,
F: FnOnce(Self::Item) -> U, { ... } fn map_err<F, U>(self, f: F) -> MapErr<Self, F>
where
Self: Sized,
F: FnOnce(Self::Error) -> U, { ... } fn and_then<F, Fut>(self, f: F) -> AndThen<Self, F>
where
Self: Sized,
F: FnOnce(Self::Item) -> Fut,
Fut: IntoFuture<Error = Self::Error>, { ... } fn or_else<F, Fut>(self, f: F) -> OrElse<Self, F>
where
Self: Sized,
F: FnOnce(Self::Error) -> Fut,
Fut: IntoFuture<Item = Self::Item>, { ... } fn then<F, Fut>(self, f: F) -> Then<Self, F>
where
Self: Sized,
F: FnOnce(Result<Self::Item, Self::Error>) -> Fut,
Fut: IntoFuture, { ... } fn from_err<T>(self) -> FromErr<Self, T>
where
Self: Sized,
T: From<Self::Error>, { ... } fn inspect<F>(self, f: F) -> Inspect<Self, F>
where
Self: Sized,
F: FnOnce(&Self::Item), { ... } }
A HTTP endpoint, which provides the futures from incoming HTTP requests
Associated Types
type Item
The type of resolved value, created by this endpoint
type Error
type Future: Future<Item = Self::Item, Error = Self::Error>
The type of future created by this endpoint
Required Methods
fn apply(self, ctx: &mut Context) -> EndpointResult<Self::Future>
Apply the incoming HTTP request, and return the future of its response
Provided Methods
fn join<E>(self, e: E) -> (Self, E) where
Self: Sized,
E: Endpoint<Error = Self::Error>,
Self: Sized,
E: Endpoint<Error = Self::Error>,
Combine itself and the other endpoint, and create a combinator which returns a pair of its
Item
s.
fn join3<E1, E2>(self, e1: E1, e2: E2) -> (Self, E1, E2) where
Self: Sized,
E1: Endpoint<Error = Self::Error>,
E2: Endpoint<Error = Self::Error>,
Self: Sized,
E1: Endpoint<Error = Self::Error>,
E2: Endpoint<Error = Self::Error>,
Combine itself and two other endpoints, and create a combinator which returns a tuple of its
Item
s.
fn join4<E1, E2, E3>(self, e1: E1, e2: E2, e3: E3) -> (Self, E1, E2, E3) where
Self: Sized,
E1: Endpoint<Error = Self::Error>,
E2: Endpoint<Error = Self::Error>,
E3: Endpoint<Error = Self::Error>,
Self: Sized,
E1: Endpoint<Error = Self::Error>,
E2: Endpoint<Error = Self::Error>,
E3: Endpoint<Error = Self::Error>,
Combine itself and three other endpoints, and create a combinator which returns a tuple of its
Item
s.
fn join5<E1, E2, E3, E4>(
self,
e1: E1,
e2: E2,
e3: E3,
e4: E4
) -> (Self, E1, E2, E3, E4) where
Self: Sized,
E1: Endpoint<Error = Self::Error>,
E2: Endpoint<Error = Self::Error>,
E3: Endpoint<Error = Self::Error>,
E4: Endpoint<Error = Self::Error>,
self,
e1: E1,
e2: E2,
e3: E3,
e4: E4
) -> (Self, E1, E2, E3, E4) where
Self: Sized,
E1: Endpoint<Error = Self::Error>,
E2: Endpoint<Error = Self::Error>,
E3: Endpoint<Error = Self::Error>,
E4: Endpoint<Error = Self::Error>,
Combine itself and four other endpoints, and create a combinator which returns a tuple of its
Item
s.
fn with<E>(self, e: E) -> With<Self, E> where
Self: Sized,
E: Endpoint,
Self: Sized,
E: Endpoint,
Combine itself and the other endpoint, and create a combinator which returns E::Item
.
fn skip<E>(self, e: E) -> Skip<Self, E> where
Self: Sized,
E: Endpoint,
Self: Sized,
E: Endpoint,
Combine itself and the other endpoint, and create a combinator which returns Self::Item
.
fn or<E>(self, e: E) -> Or<Self, E> where
Self: Sized,
E: Endpoint<Item = Self::Item, Error = Self::Error>,
Self: Sized,
E: Endpoint<Item = Self::Item, Error = Self::Error>,
Create an endpoint which attempts to apply self
.
If self
failes, then revert the context and retry applying e
.
fn map<F, U>(self, f: F) -> Map<Self, F> where
Self: Sized,
F: FnOnce(Self::Item) -> U,
Self: Sized,
F: FnOnce(Self::Item) -> U,
Combine itself and a function to change the return value to another type.
fn map_err<F, U>(self, f: F) -> MapErr<Self, F> where
Self: Sized,
F: FnOnce(Self::Error) -> U,
Self: Sized,
F: FnOnce(Self::Error) -> U,
Combine itself and a function to change the error value to another type.
fn and_then<F, Fut>(self, f: F) -> AndThen<Self, F> where
Self: Sized,
F: FnOnce(Self::Item) -> Fut,
Fut: IntoFuture<Error = Self::Error>,
Self: Sized,
F: FnOnce(Self::Item) -> Fut,
Fut: IntoFuture<Error = Self::Error>,
fn or_else<F, Fut>(self, f: F) -> OrElse<Self, F> where
Self: Sized,
F: FnOnce(Self::Error) -> Fut,
Fut: IntoFuture<Item = Self::Item>,
Self: Sized,
F: FnOnce(Self::Error) -> Fut,
Fut: IntoFuture<Item = Self::Item>,
fn then<F, Fut>(self, f: F) -> Then<Self, F> where
Self: Sized,
F: FnOnce(Result<Self::Item, Self::Error>) -> Fut,
Fut: IntoFuture,
Self: Sized,
F: FnOnce(Result<Self::Item, Self::Error>) -> Fut,
Fut: IntoFuture,
fn from_err<T>(self) -> FromErr<Self, T> where
Self: Sized,
T: From<Self::Error>,
Self: Sized,
T: From<Self::Error>,
fn inspect<F>(self, f: F) -> Inspect<Self, F> where
Self: Sized,
F: FnOnce(&Self::Item),
Self: Sized,
F: FnOnce(&Self::Item),
Implementors
impl<T: FromBody> Endpoint for Body<T> type Item = T; type Error = ParseBodyError<T::Error>; type Future = ParseBody<T>;
impl<E, F, Fut> Endpoint for AndThen<E, F> where
E: Endpoint,
F: FnOnce(E::Item) -> Fut,
Fut: IntoFuture<Error = E::Error>, type Item = Fut::Item; type Error = Fut::Error; type Future = AndThen<E::Future, Fut, F>;impl<E, T> Endpoint for FromErr<E, T> where
E: Endpoint,
T: From<E::Error>, type Item = E::Item; type Error = T; type Future = FromErr<E::Future, T>;impl<E, F> Endpoint for Inspect<E, F> where
E: Endpoint,
F: FnOnce(&E::Item), type Item = E::Item; type Error = E::Error; type Future = Inspect<E::Future, F>;impl<E, F, R> Endpoint for Map<E, F> where
E: Endpoint,
F: FnOnce(E::Item) -> R, type Item = R; type Error = E::Error; type Future = Map<E::Future, F>;impl<E, F, R> Endpoint for MapErr<E, F> where
E: Endpoint,
F: FnOnce(E::Error) -> R, type Item = E::Item; type Error = R; type Future = MapErr<E::Future, F>;impl<T> Endpoint for EndpointOk<T> type Item = T; type Error = NoReturn; type Future = FutureResult<T, NoReturn>;
impl<E1, E2, T, E> Endpoint for Or<E1, E2> where
E1: Endpoint<Item = T, Error = E>,
E2: Endpoint<Item = T, Error = E>, type Item = T; type Error = E; type Future = OrFuture<E1::Future, E2::Future>;impl<E, F, Fut> Endpoint for OrElse<E, F> where
E: Endpoint,
F: FnOnce(E::Error) -> Fut,
Fut: IntoFuture<Item = E::Item>, type Item = Fut::Item; type Error = Fut::Error; type Future = OrElse<E::Future, Fut, F>;impl<A, B, Err> Endpoint for (A, B) where
A: Endpoint<Error = Err>,
B: Endpoint<Error = Err>, type Item = (A::Item, B::Item); type Error = Err; type Future = Join<A::Future, B::Future>;impl<A, B, C, Err> Endpoint for (A, B, C) where
A: Endpoint<Error = Err>,
B: Endpoint<Error = Err>,
C: Endpoint<Error = Err>, type Item = (A::Item, B::Item, C::Item); type Error = Err; type Future = Join3<A::Future, B::Future, C::Future>;impl<A, B, C, D, Err> Endpoint for (A, B, C, D) where
A: Endpoint<Error = Err>,
B: Endpoint<Error = Err>,
C: Endpoint<Error = Err>,
D: Endpoint<Error = Err>, type Item = (A::Item, B::Item, C::Item, D::Item); type Error = Err; type Future = Join4<A::Future, B::Future, C::Future, D::Future>;impl<A, B, C, D, E, Err> Endpoint for (A, B, C, D, E) where
A: Endpoint<Error = Err>,
B: Endpoint<Error = Err>,
C: Endpoint<Error = Err>,
D: Endpoint<Error = Err>,
E: Endpoint<Error = Err>, type Item = (A::Item, B::Item, C::Item, D::Item, E::Item); type Error = Err; type Future = Join5<A::Future, B::Future, C::Future, D::Future, E::Future>;impl<E1, E2> Endpoint for Skip<E1, E2> where
E1: Endpoint,
E2: Endpoint, type Item = E1::Item; type Error = E1::Error; type Future = E1::Future;impl<E, F, Fut> Endpoint for Then<E, F> where
E: Endpoint,
F: FnOnce(Result<E::Item, E::Error>) -> Fut,
Fut: IntoFuture, type Item = Fut::Item; type Error = Fut::Error; type Future = Then<E::Future, Fut, F>;impl<E1, E2> Endpoint for With<E1, E2> where
E1: Endpoint,
E2: Endpoint, type Item = E2::Item; type Error = E2::Error; type Future = E2::Future;impl<H: Header + Clone> Endpoint for Header<H> type Item = H; type Error = NoReturn; type Future = FutureResult<Self::Item, Self::Error>;
impl<H: Header + Clone> Endpoint for HeaderOpt<H> type Item = Option<H>; type Error = NoReturn; type Future = FutureResult<Self::Item, Self::Error>;
impl<E: Endpoint> Endpoint for MatchMethod<E> type Item = E::Item; type Error = E::Error; type Future = E::Future;
impl<'a> Endpoint for &'a str type Item = (); type Error = NoReturn; type Future = FutureResult<Self::Item, Self::Error>;
impl Endpoint for String type Item = (); type Error = NoReturn; type Future = FutureResult<Self::Item, Self::Error>;
impl<'a> Endpoint for Cow<'a, str> type Item = (); type Error = NoReturn; type Future = FutureResult<Self::Item, Self::Error>;
impl<T: FromParam> Endpoint for Path<T> type Item = T; type Error = NoReturn; type Future = FutureResult<Self::Item, Self::Error>;
impl<I, T> Endpoint for PathSeq<I, T> where
I: FromIterator<T> + Default,
T: FromParam, type Item = I; type Error = NoReturn; type Future = FutureResult<Self::Item, Self::Error>;impl<T: FromStr> Endpoint for Query<T> type Item = T; type Error = NoReturn; type Future = FutureResult<Self::Item, Self::Error>;
impl<T: FromStr> Endpoint for QueryOpt<T> type Item = Option<T>; type Error = NoReturn; type Future = FutureResult<Self::Item, Self::Error>;