Closed cdecompilador closed 2 years ago
Hi, this is a good idea.
I'm not really happy with the current design for building a new Connection
.
There is one requirement I have to respect is that to safely implement Send
and Sync
, the extension data cache (Connection::ext_data
field) must be immutable and entirely initialized in the Connection
constructor.
But with an external builder, there is no such requirement. Here I can also reduce the number of constructors, because it is a little bit messy.
Ok I will start working on it :)
One question, the implementations of connect_*
in Connect
should remain or be removed? (If they have to be removed I will fix all the examples/tests don't worry)
One question, the implementations of connect_* in Connect should remain or be removed?
Please leave them in. Quite a few people are already using the beta, I don't want to break anything at this point.
In this case I think that a more idiomatic approach could be better, at the moment is just
connect_*
with many options, also there are some,from_*
, my suggestion is to use the builder pattern and just maintain in theConnection
struct theconnect
, and the simplefrom_*
(Also remaining both ways to interact with the api would be ok)My implementation
Currently
I've included a basic implementation, just in case you don't like the idea. The
with_extensions(&[xcb::Extension::Glx])
could be easily replaced bywith_extensions(xcb::Extension::Glx)
for just 1 item with some trait magic, also there are some crates to auto generate this pattern but I'm not very into them, those are also an option.