Skip to content
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

Consider passing around Vec<ASN1Block> instead of slices in FromASN1 #2

Open
mehcode opened this issue Oct 23, 2018 · 3 comments
Open

Comments

@mehcode
Copy link
Contributor

mehcode commented Oct 23, 2018

This would allow for allocation-less parsing. Currently it's required to clone data from the ASN1Blocks to move it into domain objects.

@mehcode mehcode changed the title Consider passing around mutable slices in FromASN1 Consider passing around Vec<ASN1Block> instead of slices in FromASN1 Oct 23, 2018
@acw
Copy link
Owner

acw commented Oct 30, 2018

OK, now that I'm looking at this, I'm not sure I understand your concern. Do you have an example you can share?

In particular, the library passes around slices specifically to avoid having to do deep copies. So the only thing that should be being duplicated is a ptr/start/end construct, not the ASN1Blocks within it. I did a quick check to validate this; I removed the Clone derive on ASN1Block, and it didn't appear to have much of an effect either on the library (messed with the tests, but that's it) or a little x509 library I've been building around this one. But maybe I'm missing a critical use case?

@mehcode
Copy link
Contributor Author

mehcode commented Nov 6, 2018

I meant in the FromASN1 and ToASN1 traits. See https://github.com/hashgraph/hedera-sdk-rust/blob/e6c4958eb32e60f0fb6195e8daad81aca4aefaab/src/key.rs#L85-L86

Sorry for the delay in responding. I was waiting for the ability to make my work public so I could share the issue I was having.

I either need to be able to thread a lifetime through during deserialization or be able to pop off ASN1Blocks and move the memory inside of the struct.


Also we can definitely macro this up. Would you mind me contributing some derive macros for ToASN1 and FromASN1?

@acw
Copy link
Owner

acw commented Nov 15, 2018

OK, I get it. I'm not sure what the best way forward is, but I'm currently thinking something like a mutable iterator. Let me play around with it.

Also, I'd be happy to accept derive macros.

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

No branches or pull requests

2 participants