-
Notifications
You must be signed in to change notification settings - Fork 1
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 various new OIDs, types and methods #14
Conversation
This looks good to me. I just had one question about whether a lifetime change was compatible or not. |
@@ -113,8 +113,8 @@ impl<'e, K: DerWrite> DerWrite for CertificationRequestInfo<'e, K> { | |||
} | |||
} | |||
|
|||
impl<K: BERDecodable> BERDecodable for CertificationRequestInfo<'static, K> { | |||
fn decode_ber<'a, 'b>(reader: BERReader<'a, 'b>) -> ASN1Result<Self> { | |||
impl<'a, K: BERDecodable> BERDecodable for CertificationRequestInfo<'a, K> { |
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.
Is this change compatible? There's a lifetime change here.
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 be compatible. The original version implements BERDecodable
only for CertificationRequestInfo<'static, K>
. So any time you deserialize one of these structs, you would get one that has the static lifetime. The new version implements BERDecodable
for any lifetime, which includes the static lifetime.
You would think that implementing BERDecodable
for the static lifetime should be sufficient to cover all cases, since it can always still be coerced to a shorter lifetime. I recently encountered a situation in which that wasn't the case, though. I don't completely understand why, but the compiler was giving me this error in a piece of async code:
error: implementation of `SomeTrait` is not general enough
--> [...]
| [code omitted]
= note: `SomeStruct` must implement `SomeTrait<'0>`, for any lifetime `'0`...
= note: ...but it actually implements `SomeTrait<'static>`
The SomeTrait
was indeed only implemented for the static lifetime on SomeStruct
, just like we originally had here for CertificationRequestInfo
. Changing the trait implementation to cover all lifetimes solved that issue.
src/types.rs
Outdated
} else { | ||
reader.read_tagged_implicit(Tag::context(tag_number), |r| { | ||
match tag_number { | ||
0 => { |
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.
Can we have some constants for this numbers and a comment of where they come from?
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.
Done
1e322b2
to
5f32352
Compare
bors r=[arai-fortanix, janosimas] |
Already running a review |
Build succeeded:
|
There is a separate commit for each atomic change made. The intention of this PR is not to change anything in a non-backwards compatible way. Therefore this PR only bumps the patch version of this crate.
A follow-up PR will be made for non-backwards compatible changes. That PR will bump the version to 0.2.0.