pubky / pkarr

Public Key Addressable Resource Records (sovereign TLDs)
https://app.pkarr.org
MIT License
153 stars 17 forks source link

Unidiomatic use of feature flags #41

Closed rklaehn closed 4 months ago

rklaehn commented 7 months ago

Currently, the API changes depending on whether the async feature is enabled or not. E.g. the resolve function is async when the async feature is enabled, sync otherwise.

This can lead to trouble due to the way the rust feature flag system works. Features are supposed to be additive, so adding async should only add new methods and not change the signature of existing methods.

Even if it is ugly, it would be more correct to either prepend _async to the fns or have an entire async module that gets enabled due to the feature flag.

This would require increasing the major version number though, so maybe best combine it with other API changes.

Nuhvi commented 4 months ago

Version 2 is using 3 features dht, async and relay each corresponds to a separate client. I think that should fix feature flags, but I would love if you check before I close this issue.