Error Handling in Middleware
TimeoutError<E> wraps the inner error:
enum TimeoutError<E> {
Elapsed,
Service(E),
}
Callers must handle both cases. This is a general Tower pattern: middleware adds error variants.
tower::util::MapErr can flatten if callers want a single error type:
service.map_err(|e| match e { TimeoutError::Elapsed => MyErr::Timeout, TimeoutError::Service(e) => e.into() })