See the constraint/bounds for S, could that not be aliased to be something like ActixService<B>?
As a learner of Rust, it seems like this stuff could be condensed and made less cognitively demanding. The intention of this question is about:
whether it is possible
whether it is but the Actix devs just didn't (yet)
whether it's not possible, and
whether it should be made possible in future Rust
// Middleware factory is `Transform` trait
// `S` - type of the next service
// `B` - type of response's body
impl<S, B> Transform<S, ServiceRequest> for SayHi
where
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
S::Future: 'static,
B: 'static,
{
type Response = ServiceResponse<B>;
type Error = Error;
type InitError = ();
type Transform = SayHiMiddleware<S>;
type Future = Ready<Result<Self::Transform, Self::InitError>>;
fn new_transform(&self, service: S) -> Self::Future {
ready(Ok(SayHiMiddleware { service }))
}
}