Skip to content

Server/Router type signatures are not grok-able #874

@iitalics

Description

@iitalics

Bug Report

Version

0.6.2

Platform

any

Crates

tonic

Description

The type signatures in the Server/Router builders are convoluted and reference private types, which makes them completely un-understandable to users.

For example, from tonic::transport::server::Router:

pub async fn serve<ResBody>(self, addr: SocketAddr) -> Result<(), Error> where
    L: Layer<Routes<A, B, Request<Body>>>,
    L::Service: Service<Request<Body>, Response = Response<ResBody>> + Clone + Send + 'static,
    <<L as Layer<Routes<A, B, Request<Body>>>>::Service as Service<Request<Body>>>::Future: Send + 'static,
    <<L as Layer<Routes<A, B, Request<Body>>>>::Service as Service<Request<Body>>>::Error: Into<Box<dyn Error + Send + Sync>> + Send,
    ResBody: Body<Data = Bytes> + Send + 'static,
    ResBody::Error: Into<Box<dyn Error + Send + Sync>>, 

Besides this just being an incredibly complex type signature, users can't derive any information out of it because the type Routes is private. In particular, you can't figure out what the associated types mean (or what the constraints imply) without going to the source code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions