Skip to content

Remove unnecessary static lifetime constraint on body #4096

@Voldemat

Description

@Voldemat

Is your feature request related to a problem? Please describe.
BodyTrait is a Stream that references state that outlives invocation of serve_connection.

    loop {
        let (stream, _) = listener.accept().await?;

        let io = hyper_util::rt::TokioIo::new(stream);

        let local_state = state.clone();
        tokio::task::spawn(async move {
            if let Err(err) = hyper::server::conn::http1::Builder::new()
                .serve_connection(
                    io,
                    hyper::service::service_fn(async |request| {
                        api::root_handler(&local_state, request).await
                    }),
                )
                .await
            {
                eprintln!("Error serving connection: {:?}", err);
            };
        });
    }

Describe the solution you'd like
Replace static with named body lifetime parameter

Solution is already implemented in pr: #4045, corresponding necessary changes in hyper-util are in this pr: hyperium/hyper-util#278

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-serverArea: server.C-featureCategory: feature. This is adding a new feature.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions