hyper-util icon indicating copy to clipboard operation
hyper-util copied to clipboard

feat: impl From<Http1|Http2> for auto::Builder

Open seanmonstar opened this issue 1 year ago • 1 comments

The motivation is I wanted a way to get back to the main Builder, and this seemed to do it. Does it make sense?

cc @davidpdrsn @programatik29

seanmonstar avatar Jan 24 '24 15:01 seanmonstar

Note on this: builder.http() returns Http2Builder so using into() immediately after it works, but setting any option will return a &mut Http2Builder which we cannot get back from, so I'm not sure how useful that is in practice unless we also make the methods not take refs.

Either way the Http[12]Builder only take a mut ref to Builder, so it's possible to change http2 options and go back which I hadn't realized in #113 ; so something like this works:

                    let mut builder = auto::Builder::new(TokioExecutor::new());
    
                    builder
                        .http2()
                        .max_header_list_size(4096);
        
                    builder
                        .serve_connection_with_upgrades(stream, service_fn(hello))
                        .await;

It's a bit less pretty than just chaining operators, but that means there probably isn't any hard need for this.

martinetd avatar May 23 '24 02:05 martinetd