picky_asn1/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
pub mod bit_string;
pub mod date;
pub mod restricted_string;
pub mod tag;
pub mod wrapper;

use tag::Tag;

pub trait Asn1Type {
    const TAG: Tag;
    const NAME: &'static str;
}

impl Asn1Type for () {
    const TAG: Tag = Tag::NULL;
    const NAME: &'static str = "()";
}

impl Asn1Type for String {
    const TAG: Tag = Tag::UTF8_STRING;
    const NAME: &'static str = "String";
}

impl Asn1Type for bool {
    const TAG: Tag = Tag::BOOLEAN;
    const NAME: &'static str = "bool";
}

impl Asn1Type for u8 {
    const TAG: Tag = Tag::INTEGER;
    const NAME: &'static str = "u8";
}

impl Asn1Type for u16 {
    const TAG: Tag = Tag::INTEGER;
    const NAME: &'static str = "u16";
}

impl Asn1Type for u32 {
    const TAG: Tag = Tag::INTEGER;
    const NAME: &'static str = "u32";
}

impl Asn1Type for u64 {
    const TAG: Tag = Tag::INTEGER;
    const NAME: &'static str = "u64";
}

impl Asn1Type for u128 {
    const TAG: Tag = Tag::INTEGER;
    const NAME: &'static str = "u128";
}