pub(super) fn call_handler<'a, T>(
    t: &T,
    state: AssertUnwindSafe<State>,
) -> Box<Future<Item = Response, Error = hyper::Error> + Send + 'a>
where
    T: NewHandler + 'a,
{
    let timer = Timer::new();

    let res = catch_unwind(move || {
        // Hyper doesn't allow us to present an affine-typed `Handler` interface directly. We have
        // to emulate the promise given by hyper's documentation, by creating a `Handler` value and
        // immediately consuming it.
        t.new_handler()
            .into_future()
            .map_err(|e| e.into())
            .and_then(move |handler| {
                let AssertUnwindSafe(state) = state;

                handler.handle(state).then(move |result| match result {
                    Ok((state, res)) => finalize_success_response(timer, state, res),
                    Err((state, err)) => finalize_error_response(timer, state, err),
                })
            })
    });

    if let Ok(f) = res {
        return Box::new(
            UnwindSafeFuture::new(f)
                .catch_unwind()
                .then(finalize_catch_unwind_response),
        );
    }

    Box::new(finalize_panic_response(timer))
}
/// Instantiates a `Handler` from the given `NewHandler`, and invokes it with the request. If a
/// panic occurs from `NewHandler::new_handler` or `Handler::handle`, it is trapped and will result
/// in a `500 Internal Server Error` response.
///
/// Timing information is recorded and logged, except in the case of a panic where the timer is
/// moved and cannot be recovered.
Instantiates a `Handler` from the given `NewHandler`, and invokes it with the request.

Timing information is recorded and logged, except in the case of a panic where the timer is
moved and cannot be recovered.
Instantiates a ` Handler ` from the given ` NewHandler ` and invokes it with the request . Timing information is recorded and logged except in the case of a panic where the timer is moved and cannot be recovered .
pub(super) fn call_handler<'a, T>(
    t: &T,
    state: AssertUnwindSafe<State>,
) -> Box<Future<Item = Response, Error = hyper::Error> + Send + 'a>
where
    T: NewHandler + 'a,
{
    let timer = Timer::new();
    let res = catch_unwind(move || {
        // Hyper doesn't allow us to present an affine-typed `Handler` interface directly. We have
        // to emulate the promise given by hyper's documentation, by creating a `Handler` value and
        // immediately consuming it.
        t.new_handler()
            .into_future()
            .map_err(|e| e.into())
            .and_then(move |handler| {
                let AssertUnwindSafe(state) = state;
                handler.handle(state).then(move |result| match result {
                    Ok((state, res)) => finalize_success_response(timer, state, res),
                    Err((state, err)) => finalize_error_response(timer, state, err),
                })
            })
    });
    if let Ok(f) = res {
        return Box::new(
            UnwindSafeFuture::new(f)
                .catch_unwind()
                .then(finalize_catch_unwind_response),
        );
    }
    Box::new(finalize_panic_response(timer))
}
pub ( super ) fn call_handler < ' a , T > ( t : & T , state : AssertUnwindSafe < State > , ) -> Box < Future < Item = Response , Error = hyper :: Error > + Send + ' a > where T : NewHandler + ' a , { let timer = Timer :: new ( ) ; let res = catch_unwind ( move | | { // Hyper doesn't allow us to present an affine-typed `Handler` interface directly. We have // to emulate the promise given by hyper's documentation, by creating a `Handler` value and // immediately consuming it. t . new_handler ( ) . into_future ( ) . map_err ( | e | e . into ( ) ) . and_then ( move | handler | { let AssertUnwindSafe ( state ) = state ; handler . handle ( state ) . then ( move | result | match result { Ok ( ( state , res ) ) => finalize_success_response ( timer , state , res ) , Err ( ( state , err ) ) => finalize_error_response ( timer , state , err ) , } ) } ) } ) ; if let Ok ( f ) = res { return Box :: new ( UnwindSafeFuture :: new ( f ) . catch_unwind ( ) . then ( finalize_catch_unwind_response ) , ) ; } Box :: new ( finalize_panic_response ( timer ) ) }
Instantiates a `Handler` from the given `NewHandler`, and invokes it with the request.
Instantiates a ` Handler ` from the given ` NewHandler ` and invokes it with the request .
t
&T
state
AssertUnwindSafe<State>
t
&T
state
AssertUnwindSafe<State>