pub enum ApiVersion {
Simple(u32),
Semver(SemverTriple),
Date(u16, u8, u8),
}Expand description
An API version that supports three common schemes.
Variants are ordered: Simple < Semver < Date within each variant, and
by discriminant across variants (i.e. a Simple version is always less than
a Semver version). Use the PartialOrd / Ord implementations for
“minimum version” guards.
Variants§
Simple(u32)
Integer version: v1, v2, … (stored as the bare number).
Semver(SemverTriple)
Semantic version: 1.2.3.
Date(u16, u8, u8)
Date version: YYYY-MM-DD (stored as (year, month, day)).
Implementations§
Source§impl ApiVersion
impl ApiVersion
Sourcepub fn header_value(&self) -> String
pub fn header_value(&self) -> String
Return the value suitable for use in an Accept-Version or
Content-Version HTTP header (the display string).
§Examples
use api_bones::version::ApiVersion;
let v = ApiVersion::Simple(2);
assert_eq!(v.header_value(), "v2");Trait Implementations§
Source§impl Clone for ApiVersion
impl Clone for ApiVersion
Source§fn clone(&self) -> ApiVersion
fn clone(&self) -> ApiVersion
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ApiVersion
impl Debug for ApiVersion
Source§impl<'de> Deserialize<'de> for ApiVersion
Available on crate feature serde and (crate features std or alloc) only.
impl<'de> Deserialize<'de> for ApiVersion
Available on crate feature
serde and (crate features std or alloc) only.Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for ApiVersion
impl Display for ApiVersion
Source§impl From<ApiVersion> for String
Available on crate features std or alloc only.
impl From<ApiVersion> for String
Available on crate features
std or alloc only.Source§fn from(v: ApiVersion) -> Self
fn from(v: ApiVersion) -> Self
Converts to this type from the input type.
Source§impl FromStr for ApiVersion
Available on crate features std or alloc only.
impl FromStr for ApiVersion
Available on crate features
std or alloc only.Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Parse a version string.
Accepted formats:
vNorVN— simple integer (e.g.v1)N.N.N— semver (e.g.1.2.3)YYYY-MM-DD— date (e.g.2024-06-01)
§Errors
Returns ApiVersionParseError when s does not match any recognised format.
Source§type Err = ApiVersionParseError
type Err = ApiVersionParseError
The associated error which can be returned from parsing.
Source§impl Hash for ApiVersion
impl Hash for ApiVersion
Source§impl Ord for ApiVersion
impl Ord for ApiVersion
Source§fn cmp(&self, other: &ApiVersion) -> Ordering
fn cmp(&self, other: &ApiVersion) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for ApiVersion
impl PartialEq for ApiVersion
Source§impl PartialOrd for ApiVersion
impl PartialOrd for ApiVersion
Source§impl Serialize for ApiVersion
impl Serialize for ApiVersion
impl Eq for ApiVersion
impl StructuralPartialEq for ApiVersion
Auto Trait Implementations§
impl Freeze for ApiVersion
impl RefUnwindSafe for ApiVersion
impl Send for ApiVersion
impl Sync for ApiVersion
impl Unpin for ApiVersion
impl UnsafeUnpin for ApiVersion
impl UnwindSafe for ApiVersion
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ValidateIp for Twhere
T: ToString,
impl<T> ValidateIp for Twhere
T: ToString,
Source§fn validate_ipv4(&self) -> bool
fn validate_ipv4(&self) -> bool
Validates whether the given string is an IP V4
Source§fn validate_ipv6(&self) -> bool
fn validate_ipv6(&self) -> bool
Validates whether the given string is an IP V6
Source§fn validate_ip(&self) -> bool
fn validate_ip(&self) -> bool
Validates whether the given string is an IP