Skip to content

Should BoxFuture/BoxStream require Sync? #1752

Closed
@Nemo157

Description

@Nemo157

I was just looking at testing integrating some code with Hyper's master branch. The first problem I came across was that the existing code uses BoxStream to represent its body type, which cannot be converted into hyper::Body because it additionally wants Sync on the trait object:

pub fn wrap_stream<S>(stream: S) -> Body
where
    S: TryStream + Send + Sync + 'static,
    S::Error: Into<Box<dyn StdError + Send + Sync>>,
    Chunk: From<S::Ok>, 

I don't see why Sync would be necessary, since I see no usecases where the type is accessed concurrently from different threads, but it seems to be pretty common to require both markers for trait objects (e.g. there is Into<Box<dyn Error + Send + Sync>> but not Into<Box<dyn Error + Send>> which I have run into, and seen others run into, multiple times).

I can't think of any Send + !Sync type right now, and it seems like a niche usecase if they do exist.

cc @seanmonstar

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