Skip to content

Conversation

dishmaker
Copy link
Contributor

AnyRef, that allocates as Any with alloc feature

@tarcieri
Copy link
Member

I would prefer not to have any of these types that try to special case Cow.

We can likely do something similar to what I proposed in #1795 for Any/AnyRef using tagged pointers to store the tag for AnyRef

@tarcieri
Copy link
Member

Hmm, one problem with tagged pointers is that the Tag type can now need up to 48-bits to represent, which can't be stored in e.g. a 32-bit tagged pointer

@dishmaker
Copy link
Contributor Author

Yes, the Tag alongside &'a [u8] is a problem.

One parallel solution is:

pub struct AnyCow<'a> {
    tag: Tag,
    value: Cow<'a, BytesRef>,
}

but that wouldn't be alloc-gated on allocating variant.

@tarcieri
Copy link
Member

Upstream Cow should now work for OctetStringRef/OctetString.

Are there any other cases you think are immediately important?

@dishmaker
Copy link
Contributor Author

Since you've reworked Utf8StringRef, it's perfect. I have to play with newest der some day, and test egui ASN.1 editor to see if ergonomics/performance increased.

For minimal support of x509-cert with Cow, i think BitStringRef/BitString need similar treatment, but that wouldn't work with regular Cow.

pub(crate) issuer_unique_id: Option<BitString>,

Then, Any (aliased AttributeValue) needs some Cows:

pub struct AttributeTypeAndValue {
pub oid: AttributeType,
pub value: AttributeValue,

@tarcieri
Copy link
Member

BitString/BitStringRef could work with Cow, but it would probably involve some hacks like using tagged pointers, and storing the owned BitString as a tagged pointer.

I don't think I can't do the same with Any/AnyRef though now that tags have been changed from u8, because there's too much data to put in the pointer

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