Function regex_automata::util::wire::read_version

source ·
pub(crate) fn read_version(
    slice: &[u8],
    expected_version: u32,
) -> Result<usize, DeserializeError>
Expand description

Reads a version number from the beginning of the given slice and confirms that is matches the expected version number given. If the slice is too small or if the version numbers aren’t equivalent, this returns an error.

Upon success, the total number of bytes read is returned.

N.B. Currently, we require that the version number is exactly equivalent. In the future, if we bump the version number without a semver bump, then we’ll need to relax this a bit and support older versions.