Replies: 1 comment
-
Ok -- I figured it out -- I figured I'd share in case anyone else needs the info: for item in data.all_data {
match item {
Data::Boolean(val) => println!("data: Boolean({}) - Special message", val),
Data::Array(_) => println!("data: Array"),
Data::Structure(_) => println!("data: Structure"),
Data::BitString(_) => println!("data: BitString"),
Data::Integer(_) => println!("data: Integer"),
Data::Unsigned(_) => println!("data: Unsigned"),
Data::FloatingPoint(_) => println!("data: FloatingPoint"),
Data::OctetString(_) => println!("data: OctetString"),
Data::VisibleString(_) => println!("data: VisibleString"),
Data::GeneralizedTime(_) => println!("data: GeneralizedTime"),
Data::BinaryTime(_) => println!("data: BinaryTime"),
Data::Bcd(_) => println!("data: Bcd"),
Data::BooleanArray(_) => println!("data: BooleanArray"),
Data::ObjId(_) => println!("data: ObjId"),
Data::MMSString(_) => println!("data: MMSString"),
Data::UtcTime(_) => println!("data: UtcTime"),
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm looking at the test for iec61850.rs (https://github.com/librasn/rasn/blob/main/tests/iec61850.rs) and am trying to figure out the best way to map out the values for the all_data field.
Once the message is decoded, all data has a type of
Vec<Data>
.However, this doesn't get to the underlying data or get them into a form (at least obvious to me) that I can iterate and operate on them. Is there a recommended way to iterate through the items of all_data, and take specific actions based on their type? (i.e. if you didn't know the data types at compile time?
Admittedly, I'm not deeply experienced with Rust and I'm trying to learn the language as well as the intricacies of the ber encoding/decoding process.
I've created a test file that looks like this:
The
println!
can reveal to me the types and the value, but I'm not sure how to get at that from a programmatic perspective. Everything I've tried has failed, and looking at the debug information in RustRover and vsCode at the /** line hasn't revealed good hints.Ideas?
Beta Was this translation helpful? Give feedback.
All reactions