-
Notifications
You must be signed in to change notification settings - Fork 120
Closed
Labels
C-refactorCategory: refactor. This would improve the clarity of internal code.Category: refactor. This would improve the clarity of internal code.E-mediumEffort: medium. Some knowledge of how the internals work would be useful.Effort: medium. Some knowledge of how the internals work would be useful.
Description
As discussed in #56, it is not possible to name the full RequestStream type without frame::FrameStream being externally accessible. Namely, the return value of:
// h3/src/client.rs
pub async fn send_request(
&mut self,
req: http::Request<()>,
) -> Result<RequestStream<FrameStream<C::BidiStream>>, Error> {Cannot be stored in a struct or passed around in functions params without FrameStream being public.
I see multiple solutions to this:
- The best one in my opinion: extract a trait and return an
impl RequestStream.- Pros:
- Makes the type opaque, so future proof in case of API changes.
- Cons:
- That's not possible until async traits are a thing.
- Users will have to
Boxit if they need to store this in a struct.
- Pros:
- Make
framepublic or reexportFrameStreamin the crate's scope.- Pros:
- It's easy to implement
- Cons:
- The type is still quite long to write in downstream code
FrameStreamis externally available but will never be used directly
- Pros:
- Create type aliases like
type RequestStream = RequestStreamImpl<FrameStream<C::BidiStream>>- Pros:
- It's easy to implement
- Cons:
- It would introduce another type if we want to split the streams into a reader and a writer:
type SendStream = RequestStreamImpl<C::SendStream<B>>
- It would introduce another type if we want to split the streams into a reader and a writer:
- Pros:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-refactorCategory: refactor. This would improve the clarity of internal code.Category: refactor. This would improve the clarity of internal code.E-mediumEffort: medium. Some knowledge of how the internals work would be useful.Effort: medium. Some knowledge of how the internals work would be useful.