Function run_number_unchecked

Source
pub fn run_number_unchecked(bytes: &[u8]) -> Result<u32, ParseError>
Expand description

Returns the run number assuming that the input slice has the correct MIDAS file format.

This is useful for checking the run number of a file without having to parse its entire contents. Returns an error if the run number 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\x01\x00\x00\x00";

// Nonetheless, a "run number" can still be extracted with this function.
let run_number = midasio::run_number_unchecked(bytes)?;
assert_eq!(run_number, 1);