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

Concatenate a relative OID onto a base OID #44

Open
lilyball opened this issue Jun 17, 2021 · 3 comments
Open

Concatenate a relative OID onto a base OID #44

lilyball opened this issue Jun 17, 2021 · 3 comments

Comments

@lilyball
Copy link

I would really like to be able to concatenate relative OIDs onto base OIDs at compile-time. I'm not sure if this is actually possible, but I want to be able to write something like

const OID_BASE: Oid = oid!(1.2.840.1234);
const OID_SUB_1: Oid = oid!(OID_BASE 10);
const OID_SUB_2: Oid = oid!(OID_SUB_1 15);

Or some alternative syntax that achieves the same thing. I don't know if there's any way to achieve this without heap allocation. I really wish Rust had built-in syntax for "please flatten this array into the enclosing array literal".

The goal here is of course to be able to represent a tree of OIDs using a similar structure to how they're declared in ASN.1, instead of having to repeat the OID base everywhere.

@lilyball
Copy link
Author

After looking into proc macros some more, I'm pretty sure this isn't possible.

What should be possible though is writing an oid_tree!() macro that lets you define a whole set of OIDs, where base OIDs can have children that are prefixed by the base. I'm currently working on such a macro for my own project, but I'd love to see this crate offer it directly.

@zotho
Copy link

zotho commented Jun 18, 2021

@lilyball We can probably achieve this with changes like #45

@chifflier
Copy link
Member

I would love to see that at build time, but I don't think there is a way to resolve a symbol value in a proc-macro (or macro). Maybe #45 is a solution (see the PR for discussion).

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

3 participants