File: der_sequence_compound.rs

package info (click to toggle)
rust-asn1-rs 0.7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 996 kB
  • sloc: makefile: 13; sh: 1
file content (28 lines) | stat: -rw-r--r-- 492 bytes parent folder | download
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
use asn1_rs::*;
use hex_literal::hex;

#[derive(Debug, PartialEq, DerSequence)]
pub struct T1 {
    a: u32,
    b: u16,
    c: T2,
}

#[derive(Debug, PartialEq, DerSequence)]
pub struct T2 {
    a: u16,
}

fn main() {
    let input = &hex!("300b 020101 020102 3003020103");
    let (rem, t1) = T1::from_der(input).expect("parsing failed");
    assert!(rem.is_empty());
    assert_eq!(
        t1,
        T1 {
            a: 1,
            b: 2,
            c: T2 { a: 3 }
        }
    );
}