pub struct ApiVersion(pub u32);Expand description
An API version number.
Tuple Fields§
§0: u32Implementations§
Source§impl ApiVersion
impl ApiVersion
Sourcepub fn from_path(path: &str) -> Option<Self>
pub fn from_path(path: &str) -> Option<Self>
Extract version from a URL path prefix like /v1/....
Returns None if the path doesn’t start with /v<N>.
Sourcepub fn from_header_value(value: &str) -> Option<Self>
pub fn from_header_value(value: &str) -> Option<Self>
Extract version from a header value like "2" or "v2".
Sourcepub fn from_accept_header(accept: &str) -> Option<Self>
pub fn from_accept_header(accept: &str) -> Option<Self>
Extract version from an Accept header like application/vnd.myapi.v2+json.
Looks for a v<N> pattern within the media type.
Sourcepub fn strip_prefix(path: &str) -> &str
pub fn strip_prefix(path: &str) -> &str
Strip the version prefix from a path.
/v1/users → /users, /v2/items/5 → /items/5.
Returns the original path if no version prefix is found.
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 Display for ApiVersion
impl Display for ApiVersion
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
impl Copy 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 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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).