pub struct ProtocolVersion {
pub major: u64,
pub minor: u64,
pub patch: u64,
}Expand description
语义化版本三元组 / Semantic version triple (MAJOR.MINOR.PATCH)。
顺序按 (major, minor, patch) 字典序(derive(Ord) 字段声明序),对齐 Python order=True。
Fields§
§major: u64主版本号 / major.
minor: u64次版本号 / minor.
patch: u64修订号 / patch.
Implementations§
Source§impl ProtocolVersion
impl ProtocolVersion
Sourcepub const fn new(major: u64, minor: u64, patch: u64) -> ProtocolVersion
pub const fn new(major: u64, minor: u64, patch: u64) -> ProtocolVersion
构造版本三元组 / Construct a version triple.
Sourcepub fn parse(s: &str) -> Result<ProtocolVersion, ProtocolVersionParseError>
pub fn parse(s: &str) -> Result<ProtocolVersion, ProtocolVersionParseError>
解析 MAJOR.MINOR.PATCH;段数不为 3 或非整数均返回错误。
Parse MAJOR.MINOR.PATCH; not exactly 3 integer parts → error。
严格 3 段:对齐协议 versioning.md 参考实现与 Python version.py——"0.2"(2 段)
视为非法。SDK 暴露的 crate::PROTOCOL_VERSION 恒为 3 段,握手 query 始终传 3 段。
§Errors
段数 ≠ 3、含空段或非数字段(含负号 / 溢出 u64)时返回 ProtocolVersionParseError。
Trait Implementations§
Source§impl Clone for ProtocolVersion
impl Clone for ProtocolVersion
Source§fn clone(&self) -> ProtocolVersion
fn clone(&self) -> ProtocolVersion
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for ProtocolVersion
Source§impl Debug for ProtocolVersion
impl Debug for ProtocolVersion
Source§impl Display for ProtocolVersion
impl Display for ProtocolVersion
impl Eq for ProtocolVersion
Source§impl FromStr for ProtocolVersion
impl FromStr for ProtocolVersion
Source§type Err = ProtocolVersionParseError
type Err = ProtocolVersionParseError
The associated error which can be returned from parsing.
Source§fn from_str(
s: &str,
) -> Result<ProtocolVersion, <ProtocolVersion as FromStr>::Err>
fn from_str( s: &str, ) -> Result<ProtocolVersion, <ProtocolVersion as FromStr>::Err>
Parses a string
s to return a value of this type. Read moreSource§impl Hash for ProtocolVersion
impl Hash for ProtocolVersion
Source§impl Ord for ProtocolVersion
impl Ord for ProtocolVersion
Source§fn cmp(&self, other: &ProtocolVersion) -> Ordering
fn cmp(&self, other: &ProtocolVersion) -> Ordering
1.21.0 (const: unstable) · 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 ProtocolVersion
impl PartialEq for ProtocolVersion
Source§fn eq(&self, other: &ProtocolVersion) -> bool
fn eq(&self, other: &ProtocolVersion) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for ProtocolVersion
impl PartialOrd for ProtocolVersion
impl StructuralPartialEq for ProtocolVersion
Auto Trait Implementations§
impl Freeze for ProtocolVersion
impl RefUnwindSafe for ProtocolVersion
impl Send for ProtocolVersion
impl Sync for ProtocolVersion
impl Unpin for ProtocolVersion
impl UnsafeUnpin for ProtocolVersion
impl UnwindSafe for ProtocolVersion
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