GithubHelp home page GithubHelp logo

Use `const-oid` crate? about rasn HOT 4 CLOSED

repnop avatar repnop commented on May 20, 2024
Use `const-oid` crate?

from rasn.

Comments (4)

XAMPPRocky avatar XAMPPRocky commented on May 20, 2024

I would imagine this would likely replace the current ConstOid type in rasn, or at least be available as an opt-in feature. Thoughts?

Thank you for your issue! However I'm not quite sure what the benefits would be for integrating the const-oid crate would be. AFAICT there's only difference between the textual representation and rasn::types::ConstOid is using , as a separator instead of .. That's not enough to me to introduce a crate boundary for such a fundamental type. I would use the parser to provide it as a method if that was exposed but it only provides the type.

Though I haven't made an issue for it, I do also have features and improvements to the API that I'd still like to add to the OID types, and want to keep a good amount of flexibility. For example, I'd like to be write the following in the future, which would allow you to share and re-use oid arcs like you can in the ASN.1 language.

oid! { iso(1), IDENTIFIED_ORGANISATION(3), DOD(6), INTERNET(6) }
oid! { ISO_IDENTIFIED_ORGANISATION_DOD_INTERNET, DIRECTORY(1) }

// Generates

const  ISO_IDENTIFIED_ORGANISATION: Oid = oid![1, 3];
const  ISO_IDENTIFIED_ORGANISATION_DOD: Oid = oid![ISO_IDENTIFIED_ORGANISATION, 6];
const  ISO_IDENTIFIED_ORGANISATION_DOD_INTERNET: Oid = oid![DOD, 1];
const  ISO_IDENTIFIED_ORGANISATION_DOD_INTERNET_DIRECTORY: Oid = oid![ISO_IDENTIFIED_ORGANISATION_DOD_INTERNET, 1];

from rasn.

repnop avatar repnop commented on May 20, 2024

Gotcha, understandable. The current code that I work with at my job uses the string . notation pretty much everywhere which is why const-oid caught my eye (I also think its a bit easier to read as its more compact, and avoids the need for a proc macro for parsing), and figured I'd mention it in case it was useful enough to reduce the number of competing OID types. Thank you for the quick response 😃

from rasn.

XAMPPRocky avatar XAMPPRocky commented on May 20, 2024

(I also think its a bit easier to read as its more compact, and avoids the need for a proc macro for parsing

Well just to be clear, I used macro syntax above, but what I proposed could be done in const once there's the ability to have const trait, and I am waiting on const to get more featureful to add those kinds of features.

figured I'd mention it in case it was useful enough to reduce the number of competing OID types.

I mean I think it would be fair to ask const-oid maintainers if they'd want to add optional rasn definitions. The conversion would be there just in const-oid rather than rasn. The whole point of rasn's design to allow you to reuse different types across crates. Just like how certain crates have a serde feature to enable serialisation.

from rasn.

repnop avatar repnop commented on May 20, 2024

Yup that seems reasonable to me, if I decide to use it, I'll open an issue on their repo

from rasn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.