pub struct EngineVersion { /* private fields */ }Expand description
A version of an engine: 17, 8.4, 2022, 23ai.
Ordered by its numbers, the missing ones read as zero, so 8.4 is newer
than 8 and the same as 8.4.0. The letters after the last digit are
part of how the vendor writes it and not of its order: 23ai and 23 are
one version, and a dialect that declares 23ai answers to oracle@23 too.
It is displayed as it was written, so a refusal and a manifest say the version in the user’s words.
use razeri_plugin_contract::EngineVersion;
let floor = EngineVersion::declared("15");
let asked: EngineVersion = "17".parse().unwrap();
assert!(floor < asked);
assert_eq!(asked.to_string(), "17");
assert_eq!("23ai".parse::<EngineVersion>().unwrap(), "23".parse().unwrap());Implementations§
Source§impl EngineVersion
impl EngineVersion
Sourcepub const fn declared(spelling: &str) -> Self
pub const fn declared(spelling: &str) -> Self
A version a dialect declares, read when the program is compiled.
A spelling that is not a version stops the build, so a dialect’s
declared list can be a const:
use razeri_plugin_contract::EngineVersion;
const VERSIONS: &[EngineVersion] =
&[EngineVersion::declared("15"), EngineVersion::declared("17")];
assert_eq!(VERSIONS[0].to_string(), "15");§Panics
When spelling is not a version; in a const, that is a compile
error.
Sourcepub fn parse(spelling: &str) -> Result<Self, EngineVersionError>
pub fn parse(spelling: &str) -> Result<Self, EngineVersionError>
Read a version written by a user.
§Errors
EngineVersionError naming what is wrong and, where there is one,
the spelling that is accepted.