-
Notifications
You must be signed in to change notification settings - Fork 940
Open
Description
I have a question about the visibility of DefaultBufFactory and whether this is an intentional design choice.
I would like to create a generic data structure around quiche::Connection so that it can work with either a custom BufFactory or the default one. For example:
struct ConnectionMap<F: BufFactory>(HashMap<usize, Connection<F>>);
This works fine with a custom implementation:
ConnectionMap::<MyCustomBufFactory>::new();
However, because DefaultBufFactory is private, I can’t instantiate the same structure using the default buffer factory:
ConnectionMap::<DefaultBufFactory>::new(); // not possible
As a workaround, I can define two separate types:
struct ConnectionMapWithBufFactory<F: BufFactory>(HashMap<usize, Connection<F>>);
struct ConnectionMapWithoutBufFactory(HashMap<usize, Connection>);
But this quickly propagates to other structs and forces duplication or additional abstraction such as:
trait ConnectionMapWithOrWithoutBufFactory {}
impl ConnectionMapWithOrWithoutBufFactory for ConnectionMapWithBufFactory {}
impl ConnectionMapWithOrWithoutBufFactory for ConnectionMapWithoutBufFactory {}
struct Endpoint<M: ConnectionMapWithOrWithoutBufFactory> { ... }
Should DefaultBufFactory be public?
Metadata
Metadata
Assignees
Labels
No labels