rust-http2
rust-http2 copied to clipboard
Change API from Stream to Sink
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
Streamis 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.