kellerkindt / asn1rs

Generates Rust Code and optionally compatible Protobuf schema files from ASN.1 definitions.
http://asn1.rs
Apache License 2.0
55 stars 20 forks source link

Solve character string types in a nicer way #48

Open kellerkindt opened 3 years ago

kellerkindt commented 3 years ago

Currently each character string type has its own read_*/write_* fn which every Reader/Writer must implement


    fn read_utf8string<C: utf8string::Constraint>(&mut self) -> Result<String, Self::Error>;

    fn read_ia5string<C: ia5string::Constraint>(&mut self) -> Result<String, Self::Error>;

    fn read_numeric_string<C: numericstring::Constraint>(&mut self) -> Result<String, Self::Error>;

    fn read_visible_string<C: visiblestring::Constraint>(&mut self) -> Result<String, Self::Error>;

    fn read_printable_string<C: printablestring::Constraint>(
        &mut self,
    ) -> Result<String, Self::Error>;

Consider a common fn (like read_characters?) and pass the Charset as (type) parameter? Same with the Utf8String, Ia5String, ... types.