rust-http2 icon indicating copy to clipboard operation
rust-http2 copied to clipboard

Change API from Stream to Sink

Open stepancheg opened this issue 7 years ago • 0 comments

Currently, client and server APIs are basically:

fn start_request(Headers, request_body: Stream<Part>) -> Stream<Part>;

The client invokes this function and server provides a callback for that function.

  • this API is not very easy API to use, because Stream is not trivial to implement (request for a client and response for a server)
  • httpbis library requires to spawn a separate task just to "pull" from a provided stream, because of that httpbis performs additional work when user implementation already has a task which provides data

The proposed API should be like this:

// client:
fn start_request(Headers) -> (Sink<Part>, Stream<Part>); // return a request sink and response stream
// server
fn start_request(Headers, request: Stream<Part>, response: Sink<Part>);

Note h2 library and grpc-rs use similar APIs.

stepancheg avatar Oct 28 '18 20:10 stepancheg