Skip to content

Upgraded::downcast_ref is unusable with hyper_util::server::conn::auto #3704

@nox

Description

@nox

hyper_util::server::conn::auto::Connection<'a, I, S, E> internally wraps I in hyper_util::common::rewind::Rewind<_>, which is a private type, so we cannot ever make use of Upgraded::downcast_ref anymore.

While I could expose Rewind<_> in hyper_util and improve docs in hyper_util::server::conn::auto to signal that one should be downcasting to Rewind<I>, I am filing this in hyper because I thought of a potentially better resolution:

  1. Introduce hyper::server::conn::http1::Builder::serve_buffered_connection:

    impl Builder {
        pub fn serve_buffered_connection<I, S>(&self, buffered: Bytes, io: I, service: S) -> Connection<I, S>
        where
            S: HttpService<IncomingBody>,
            S::Error: Into<Box<dyn StdError + Send + Sync>>,
            S::ResBody: 'static,
            <S::ResBody as Body>::Error: Into<Box<dyn StdError + Send + Sync>>,
            I: Read + Write + Unpin,
        {
            let mut conn = proto::Conn::new_buffered(buffered, io);}
    }
  2. Use that in hyper_util::server::conn::auto::Builder::serve_connection instead of wrapping I into Rewind<_>.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-featureCategory: feature. This is adding a new feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions