LTV

ltv="0.1"


Basic usage

```Rust

[derive(Debug, PartialEq, Eq)]

struct BasicLTV{ field1: u8, }

impl<'a> LTVItem<'a, ed::BE> for BasicLTV { type Item = BasicLTV; fn fromltv(: usize, data: &'a [u8]) -> LTVResult { let reader = LTVReader::::new(data); Ok(BasicLTV{ field1: reader.getitem::(0x01)?, }) } fn toltv(&self) -> Vec { let mut buffer = Vec::withcapacity(3); buffer.writeltv(0x01, &self.field1).ok(); buffer } } Rust let original = BasicLTV{ field1: 0x35 };

// toltv only returns the [v] infomation of an object let buffer = original.toltv();

let out = BasicLTV::fromltv(0x01, &buffer).unwrap(); asserteq!(original, out); assert_eq!(&buffer, &[2, 0x01, 0x35]); ```

Struct Reading

```Rust

[derive(Debug, PartialEq, Eq)]

struct innerstructdata { field1: u8, field2: u16 } impl LTVItem<', ED> for innerstructdata { type Item = innerstructdata; fn fromltv(field_id:usize, data: &[u8]) -> LTVResult { let reader = LTVReader::::new(&data);

    Ok(
        inner_struct_data{
            field1: reader.get_item::<u8>(0x1)?,
            field2: reader.get_item::<u16>(0x2)?,
        }
    )
}

fn to_ltv(&self) -> Vec<u8>{
    unimplemented!()
}

} ```

```Rust let inputdata : &[u8] = &[ 0x04, 0x01, 0x02, 0x01, 0xFF, 0x08, 0x02, 0x02, 0x01, 0x55, 0x03, 0x02, 0x01, 0x00 ]; let reader = LTVReader::::new(&inputdata[2..]);

let field1 = reader.getitem::(0x1).unwrap(); asserteq!(field1, 0xFF);

let field2 = reader.getitem::(0x2).unwrap(); asserteq!(field2, innerstructdata{ field1: 0x55, field2: 0x0100 }); ```