-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose dropshot's http and hyper dependencies #250
Conversation
Users constructing dropshot::HttpError manually do not have access to the StatusCode type, and instead of requiring them to keep their http dependency in sync with dropshot expose dropshot's StatusCode. That way, users can do: HttpError { status_code: dropshot::StatusCode::NOT_FOUND, ... }
Good idea! I like it. @davepacheco any objections? |
I might even propose generalizing this to expose dropshot's
|
Plus hyper? :) |
Yeah, I can see how this is annoying for consumers. But would exposing I remember running into problems with a similar idea under #70. But I think in that case the reason is had to do with the crate in question (json-schema) exposing a macro. I don't think we're using http or hyper macros here. I wonder if the same advice is worthwhile: try updating |
(sorry for the double-comment) I think some crates do use this pattern of publicly exposing some internal dependency. I went to check hyper, which exposes some Are there any guidelines on this best practice? I did find this draft. I found a few other discussions. It seems like this is reasonably idiomatic? |
I can't speak to how idiomatic it is, but I got the idea from tokio-rustls. I was also searching for a way for cargo to track the dependency of a dependency, but that seems a little more heavy. This way when dropshot updates a dependency there aren't any changes to consumer code. |
(sorry again -- I should probably finish whatever digging I'm going to do before commenting here :-/) Interestingly, I'm not the only one that finds that doc behavior confusing. And this comment about whether every crate that exposes future-stuff ought to re-export |
This sentence made me think that it would be better if Cargo could follow a dependency of a dependency. Some fake syntax in omicron like:
which interestingly could enforce that foo and dropshot have matching http versions (does Cargo already complain if the http versions can't be made to match?). But this would complicate the dep graph quite a bit I think. |
@davepacheco FWIW I believe the issue with #70 as it pertained to |
Closing this |
Users constructing dropshot::HttpError manually do not have access to
the StatusCode type, and instead of requiring them to keep their http
dependency in sync with dropshot expose dropshot's StatusCode. That way,
users can do: