rust_parser/ber_tlv/
mod.rs

1pub(crate) mod tag_length;
2pub mod tlv_parser_error;
3
4use crate::traits::FileParser;
5use std::io::{BufReader, Read};
6
7use self::tag_length::TagLength;
8
9#[derive(Debug)]
10pub struct BerTlv<'a> {
11    _tag_length: Vec<TagLength>,
12    _offset: usize,
13    file: &'a str,
14}
15
16impl<'a> FileParser for BerTlv<'a> {
17    fn print(&self) {
18        let file = self.open();
19        let buf_reader = BufReader::new(file);
20
21        for (_i, byte) in buf_reader.bytes().enumerate() {
22            if let Ok(data) = byte {
23                print!("{:02X}", data);
24            }
25        }
26    }
27
28    fn write_to_file(&self) {
29        todo!()
30    }
31
32    fn get_file_path(&self) -> &str {
33        self.file
34    }
35}
36
37impl<'a> BerTlv<'a> {
38    pub(crate) fn new(file: &'a str) -> BerTlv {
39        let tlv_parser = BerTlv {
40            _offset: 0,
41            file,
42            _tag_length: vec![TagLength {
43                _val_offset: 0,
44                _tag: vec![1, 2, 3, 4],
45                _len: 3,
46            }],
47        };
48
49        tlv_parser.print();
50        return tlv_parser;
51    }
52}