Skip to content

x509-cert: draft: TbsCertificateInner generic over DerMemory trait #1826

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dishmaker
Copy link
Contributor

Im stuck on invariant lifetime.

lifetime may not live long enough
requirement occurs because of the type `CertificateInner<'_, AllocDerMemory, P>`, which makes the generic argument `'_` invariant
the struct `CertificateInner<'m, MEM, P>` is invariant over the parameter `'m`
see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance

anchor.rs(94, 6): lifetime `'__der_lifetime` defined here

Adding der::Cow looks easier, i think 🤔

@tarcieri
Copy link
Member

I'm not sure what you're trying to accomplish with this

@dishmaker
Copy link
Contributor Author

I want to make Ref and Owned types from TbsCertificateInner.

/// [`PrivateKeyInfo`] with [`AnyRef`] algorithm parameters, and `&[u8]` key.
pub type PrivateKeyInfoRef<'a> = PrivateKeyInfo<AnyRef<'a>, OctetStringRef<'a>, BitStringRef<'a>>;
/// [`PrivateKeyInfo`] with [`Any`] algorithm parameters, and `Box<[u8]>` key.
#[cfg(feature = "alloc")]
pub type PrivateKeyInfoOwned = PrivateKeyInfo<Any, OctetString, BitString>;

@tarcieri
Copy link
Member

It would probably be good to flesh out a design in #1603.

Note that elsewhere we have avoided adding lifetimes except for the reference types, which can be done with generic parameters (as opposed to what you're trying to do with 'static in this PR)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants