-
Notifications
You must be signed in to change notification settings - Fork 83
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
Add back the typed representation of the Link header #113
base: master
Are you sure you want to change the base?
Conversation
f2657dc
to
369966e
Compare
ping @seanmonstar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're not part of the diff, so I can't comment at the specific line, but I think a few parts of the public API should be adjusted, so they make less promises about internals. Such as:
Link::new(Vec<_>)
- Perhaps it should benew()
, taking no arguments, to start with an empty link header.Link::values() -> &[LinkValue]
- This implies we have a contiguous slice of values, but we could conceivably place them in a different data structure (a vecdeque, or a hashmap), or even eagerly serialize them. I'd probably change this to return animpl Iterator
. Maybe some of the other types name this asiter
? I can't recall.
Sounds good! I added a I found no other occurrences of a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the couple of comments which should be quick to fix, a final check would be good: is there any type, or method, which is exposing it's internal structure? Any forwards-compatibility hazards that if we needed to change, would need a breaking change?
self.values.as_ref() | ||
/// Get an iterator over the `Link` header's `LinkValue`s. | ||
pub fn iter(&self) -> impl Iterator<Item = LinkValue> + '_ { | ||
self.values.iter().cloned() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the default iterator be cloning the values? Why not give references, and a user can clone if they need to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe so the internal storage can be changed to something that isn't a container of LinkValue
s? Happy to change this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want it changed?
@@ -25,6 +25,7 @@ bytes = "1" | |||
mime = "0.3.14" | |||
sha1 = "0.10" | |||
httpdate = "1" | |||
language-tags = "0.3.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried scrolling through to find the answer, but failed so far. We don't expose this dependency, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are, actually. LinkValue::href_lang
returns Option<&[LanguageTag]>
, and LinkValue::push_href_lang
has the parameter language_tag: LanguageTag
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you want that to change before merging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather not expose this dependency publicly, at least that's my default feeling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I feel like it shouldn't be such a big deal for headers
, as opposed to headers-core
. But I'll look into how complex it would be to remove it from public API / what the consequences would be exactly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the main reason I would like to not change the code here is that it allows push_href_lang
to be infallible. If language-tags
was required to be removed from public API, that would mean parsing the language tag provided by the user in that function. Please let me know whether you agree or not and I'll update the PR accordingly.
This is exactly #67 except it uses the latest version of language-tags and is rebased.
edit: Now one extra commit of my own, as commit authorship shows.
Closes #67.