Skip to main content

detect_version

Function detect_version 

Source
pub fn detect_version(first_line: &str) -> Result<u32, String>
Expand description

Detect the event log format version from the first line of a shard file.

The expected header format is # bones event log v<N> where N is a positive integer.

§Returns

  • Ok(version) if the header is present and the version is ≤ CURRENT_VERSION.
  • Err(message) with an actionable upgrade instruction if the version is newer than this build of bones, the header is malformed, or the version number cannot be parsed.

§Forward compatibility

A version number greater than CURRENT_VERSION means this file was written by a newer version of bones and may contain format changes that this version cannot handle. The error message instructs the user to upgrade.

§Errors

Returns an error string if the header is missing, malformed, has an unparseable version number, or the version exceeds CURRENT_VERSION.

§Backward compatibility

All prior format versions are guaranteed to be readable by this version. Version-specific parsing is dispatched via the returned version number.