#[non_exhaustive]pub enum VersionNumber {
V2_0,
V2_1,
V2_1_1,
V2_2,
V2_2_1,
V2_3_0,
Custom(String),
}Expand description
A version of the OCPI protocol, as it appears in /versions and in version details.
Listed as an OpenEnum so that discovery against a peer that speaks a version this crate
has never heard of — a future 3.0, or a version the peer invented — lists it and moves on
instead of failing. VersionNumber::is_supported says which ones this build can
actually talk.
Spec: 2.3.0 §version_information_endpoint_versionnumber_enum
This is an OCPI OpenEnum: a value this version of the specification does not
define is a legitimate extension, and Validate does
not report it.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
V2_0
OCPI version 2.0. Not modelled by this crate; recognised so discovery can skip it.
Wire value: 2.0
V2_1
OCPI version 2.1. Deprecated by the spec: “do not use, use 2.1.1 instead”.
Wire value: 2.1
V2_1_1
OCPI version 2.1.1.
Wire value: 2.1.1
V2_2
OCPI version 2.2. Deprecated by the spec: “do not use, use 2.2.1 instead”.
Wire value: 2.2
V2_2_1
OCPI version 2.2.1. Still the most widely deployed version.
Wire value: 2.2.1
V2_3_0
OCPI version 2.3.0. The canonical model of this crate.
Wire value: 2.3.0
Custom(String)
A value this version of the specification does not define, preserved verbatim.
The variant is named Custom rather than Other because several OCPI OpenEnums
have a defined value that is literally OTHER.
Implementations§
Source§impl VersionNumber
impl VersionNumber
Sourcepub const ALL_KNOWN: &'static [Self]
pub const ALL_KNOWN: &'static [Self]
Every value this version of the specification defines, in declaration order.
Sourcepub const ALL_KNOWN_WIRE: &'static [&'static str]
pub const ALL_KNOWN_WIRE: &'static [&'static str]
Every wire value this version of the specification defines.
Sourcepub fn from_str_ignore_case(s: &str) -> Self
pub fn from_str_ignore_case(s: &str) -> Self
Parses a wire value, ignoring ASCII case for the known values.
For peers that get the case wrong; FromStr is strict.
Source§impl VersionNumber
impl VersionNumber
Sourcepub fn is_supported(&self) -> bool
pub fn is_supported(&self) -> bool
Whether this build of ocpi-kit has a wire model for this version.
Depends on the enabled cargo features.
Sourcepub const fn is_deprecated(&self) -> bool
pub const fn is_deprecated(&self) -> bool
Whether the specification marks this version as deprecated.
Spec: 2.3.0 §version_information_endpoint_versionnumber_enum
Sourcepub fn supported() -> Vec<Self>
pub fn supported() -> Vec<Self>
Every version this build can talk, newest first.
This is the preference order used when negotiating with a peer.
Sourcepub const fn release_rank(&self) -> u8
pub const fn release_rank(&self) -> u8
Where this version sits in the release order, oldest first.
A version this crate does not know ranks last. This is deliberately not the Ord
impl, which sorts by wire value so that VersionNumber behaves predictably as a map key
— and note that sorting by wire value is wrong for versions, since "2.10" < "2.2"
lexically. Use VersionNumber::cmp_by_release to order them.
Sourcepub fn cmp_by_release(&self, other: &Self) -> Ordering
pub fn cmp_by_release(&self, other: &Self) -> Ordering
Orders two versions by release, oldest first; unknown versions sort last, by their text.
use ocpi_kit::VersionNumber;
let mut vs = vec![VersionNumber::V2_3_0, VersionNumber::V2_1_1, VersionNumber::V2_2_1];
vs.sort_by(VersionNumber::cmp_by_release);
assert_eq!(vs.first(), Some(&VersionNumber::V2_1_1));Sourcepub fn has_routing_headers(&self) -> bool
pub fn has_routing_headers(&self) -> bool
Whether the version uses the OCPI-to-*/OCPI-from-* message routing headers.
Routing headers were introduced in OCPI 2.2; 2.1.1 and older have no such thing.
Spec: 2.3.0 §transport_and_format_message_routing
Sourcepub fn has_credentials_roles(&self) -> bool
pub fn has_credentials_roles(&self) -> bool
Whether the version splits Credentials into a list of roles.
OCPI 2.1.1 puts party_id, country_code and business_details directly on the
credentials object; 2.2 and later moved them into CredentialsRole entries.
Trait Implementations§
Source§impl Clone for VersionNumber
impl Clone for VersionNumber
Source§fn clone(&self) -> VersionNumber
fn clone(&self) -> VersionNumber
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for VersionNumber
impl Debug for VersionNumber
Source§impl<'de> Deserialize<'de> for VersionNumber
impl<'de> Deserialize<'de> for VersionNumber
Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
Source§impl Display for VersionNumber
impl Display for VersionNumber
impl Eq for VersionNumber
Source§impl From<&str> for VersionNumber
impl From<&str> for VersionNumber
Source§impl FromStr for VersionNumber
impl FromStr for VersionNumber
Source§impl Hash for VersionNumber
impl Hash for VersionNumber
Source§impl JsonSchema for VersionNumber
Available on crate feature schema only.
impl JsonSchema for VersionNumber
schema only.Source§fn json_schema(_g: &mut SchemaGenerator) -> Schema
fn json_schema(_g: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl Ord for VersionNumber
impl Ord for VersionNumber
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for VersionNumber
impl PartialEq for VersionNumber
Source§impl PartialOrd for VersionNumber
impl PartialOrd for VersionNumber
Source§impl Serialize for VersionNumber
impl Serialize for VersionNumber
Source§impl Validate for VersionNumber
impl Validate for VersionNumber
Auto Trait Implementations§
impl Freeze for VersionNumber
impl RefUnwindSafe for VersionNumber
impl Send for VersionNumber
impl Sync for VersionNumber
impl Unpin for VersionNumber
impl UnsafeUnpin for VersionNumber
impl UnwindSafe for VersionNumber
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.