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) -> EngineVersion
pub const fn declared(spelling: &str) -> EngineVersion
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<EngineVersion, EngineVersionError>
pub fn parse(spelling: &str) -> Result<EngineVersion, EngineVersionError>
Read a version written by a user.
§Errors
EngineVersionError naming what is wrong and, where there is one,
the spelling that is accepted.
Trait Implementations§
Source§impl Clone for EngineVersion
impl Clone for EngineVersion
Source§fn clone(&self) -> EngineVersion
fn clone(&self) -> EngineVersion
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for EngineVersion
Source§impl Debug for EngineVersion
impl Debug for EngineVersion
Source§impl Display for EngineVersion
impl Display for EngineVersion
impl Eq for EngineVersion
Source§impl FromStr for EngineVersion
impl FromStr for EngineVersion
Source§type Err = EngineVersionError
type Err = EngineVersionError
Source§fn from_str(
spelling: &str,
) -> Result<EngineVersion, <EngineVersion as FromStr>::Err>
fn from_str( spelling: &str, ) -> Result<EngineVersion, <EngineVersion as FromStr>::Err>
s to return a value of this type. Read more