You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Either I don't undestand how the lib should be used or there is some fishy stuff in the code. This example should serialize an empty value and parse it back, but Tlv::from_vec returns an error:
use tlv_parser::tlv::{Tlv,Value};fnmain(){let src = Tlv::new(0x1F,Value::Nothing).unwrap();let output = src.to_vec();let dest = Tlv::from_vec(&output).unwrap();assert_eq!(dest.tag(),0x1F);}
Output:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: TruncatedTlv', src/main.rs:6:39
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The text was updated successfully, but these errors were encountered:
In your case there is an error in the tag number. BER-TLV rules imply that if most-significant-byte of a tag number masked by 0x1F is equal to 0x1F (tag & 0x1F == 0x1F) then tag number is consist of at least two bytes. In your case tag number is one byte size.
Now Tlv::new doesn't check the tag number provided by user. I will add such a check.
Either I don't undestand how the lib should be used or there is some fishy stuff in the code. This example should serialize an empty value and parse it back, but
Tlv::from_vec
returns an error:Output:
The text was updated successfully, but these errors were encountered: