pub fn initial_timestamp_unchecked(bytes: &[u8]) -> Result<u32, ParseError>
Expand description
Returns the timestamp of the initial ODB dump assuming the correct MIDAS file format.
This is useful for checking the initial timestamp of a file without having to parse its entire contents. Returns an error if the timestamp cannot be determined.
ยงExamples
// Note that the following is an invalid MIDAS file:
// - The magic midas marker is 0xFFFF instead of 0x494D.
// - Too short to even contain the rest of the header.
let bytes = b"\x00\x80\xFF\xFF\xFF\xFF\xFF\xFF\x01\x00\x00\x00";
// Nonetheless, an "initial timestamp" can still be extracted with this function.
let timestamp = midasio::initial_timestamp_unchecked(bytes)?;
assert_eq!(timestamp, 1);