Skip to main content

detect_version

Function detect_version 

Source
pub fn detect_version(data: &[u8]) -> Result<IpVersion, XdbError>
Expand description

Detect the IP version from loaded xdb data.

Parses the header and calls Header::ip_version. This is a convenience function — use Header::parse directly if you also need other header fields.

§Example

let data = xdb_parse::load_file("./assets/ip2region_v4.xdb".into())?;
let version = xdb_parse::detect_version(&data)?;
assert_eq!(version, xdb_parse::IpVersion::V4);