-
Notifications
You must be signed in to change notification settings - Fork 114
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
feat: support non utf8 strings #71
Conversation
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.
Thanks for the PR! This is an API breaking change, so requires a minor semver bump for a future release. Not sure yet if I want to wait with merging or merge it right now.
src/lib.rs
Outdated
@@ -414,11 +427,11 @@ impl DistinguishedName { | |||
removed | |||
} | |||
/// Inserts or updates an attribute that consists of type and name | |||
pub fn push(&mut self, ty :DnType, s :impl Into<String>) { | |||
pub fn push(&mut self, ty :DnType, s :DnValue) { |
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 prefer to keep the old API for the push side, as 99% of use cases would probably be UTF-8 strings. This doesn't just reduce the diff of this PR but also makes updating easier for the users. Usage of the API would also remain as easy as it used to be. Can you rename this function to push_ext
or something and say something along the lines that you should use push
unless there is a specific need to use something other than Utf8Strings
?
The get
side is fine, as I think it's less used.
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.
Would it be better to have a single method that takes an impl Into<DnValue>
and provide the following implementation?
impl<T> From<T> for DnValue
where
T :Into<String>
{
fn from(t :T) -> Self {
DnValue::Utf8String(t.into())
}
}
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.
Would it be better to have a single method that takes an impl Into and provide the following implementation?
That's a great idea! I'm a bit worried though that the impl is not immediately seen. A code example in the rustdoc that uses a str literal would solve that I think.
@est31 I have updated the PR per your suggestions. Let me know if you would prefer |
Also I'd like to see a test case for #59. Ideally it'd not use a certificate from the wild due to copyright but one you generated yourself (maybe even using rcgen). As for the breaking change, one of the possible resolutions of #65 seems to require one already, and the ring author said they wanted to make a breaking change themselves soon. |
@est31 I have added the requested example and tests. Let me know if there is anything else you would like changed/added. |
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.
OK except for nits.
fixes #59
Allows non UTF-8 values to be used for distinguished name entries