client-toolkit
client-toolkit copied to clipboard
Miscellaneous inconsistencies
There are a few inconsistencies in sctk currently. That might be worth thinking about for the next breaking version.
- It would make sense if
ProvidesBoundGlobalwere implemented for every type in the crate that provides a global.- But by the requirements of the trait, as defined, it can't be implemented for things like dmabuf, for which sctk supports versions 3 and 4. Both of which seem important to support now.
- Could be defined as an enum of states by version, each of which implements
ProvidesBoundGlobalfor different versions, or methods returning things that returnProvidesBoundGlobal, but those are awkward...
- Could be defined as an enum of states by version, each of which implements
- But by the requirements of the trait, as defined, it can't be implemented for things like dmabuf, for which sctk supports versions 3 and 4. Both of which seem important to support now.
- Some wrappers around globals have names ending in
*Statebut some don't. - Some have a constructor called
::newwhile others have one called::bind - Handling of protocols/globals that may or may not exist
-
Shm::bindreturns an error if the global doesn't exist; but implementingShmHandlerrequires returning theShm(I guess if the protocol somehow is optional for a client, it could store anOption<Shm>, and defineshm_statewith.as_mut().unwrap()?) - Some other state types have constructors that always succeed, but methods returning a
GlobalErrorresult.ProvidesBoundGlobalhandles this. Methods may fail regardless if they need a newer protocol version.
-
The use of methods on state types as helpers for sending requests is occasionally inconvenient if one wants to send requests from another thread... though in the worst cast those can be done directly. Not sure if there's a good way to define helpers than handle this case well.