Skip to content

Reason for Sync + Send + 'static #1327

Closed
@mersinvald

Description

@mersinvald

Hello!

Can you please explain reasoning behind Sync + Send + 'static bound on the NewService here

hyper/src/server/mod.rs

Lines 88 to 92 in 77bfcd9

pub fn bind<S, Bd>(&self, addr: &SocketAddr, new_service: S) -> ::Result<Server<S, Bd>>
where S: NewService<Request = Request, Response = Response<Bd>, Error = ::Error> +
Send + Sync + 'static,
Bd: Stream<Item=B, Error=::Error>,
{

and here

hyper/src/server/mod.rs

Lines 339 to 342 in 77bfcd9

impl<S, B> Server<S, B>
where S: NewService<Request = Request, Response = Response<B>, Error = ::Error>
+ Send + Sync + 'static,
B: Stream<Error=::Error> + 'static,

I've been writing my custom NewService and ran into problems with this bounds.

Are they necessary since hyper moved to async single-thread mode with Tokio?
Removing them will allow to write simpler and way more effective single-thread async 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