pub struct ProtocolVersion {
pub semantic: String,
pub git_describe: Option<String>,
pub git_hash: Option<String>,
}Expand description
Protocol version information
Contains version information for compatibility checking between rcp and rcpd. The semantic version is used for compatibility checks, while git information provides additional debugging context.
Fields§
§semantic: StringSemantic version from Cargo.toml (e.g., “0.22.0”)
This is the primary version used for compatibility checking.
git_describe: Option<String>Git describe output (e.g., “v0.21.1-7-g644da27”)
Optional. Provides detailed version information including:
- Most recent tag
- Number of commits since tag
- Short commit hash
- “-dirty” suffix if working tree has uncommitted changes
git_hash: Option<String>Full git commit hash
Optional. Useful for exact build identification and debugging.
Implementations§
Source§impl ProtocolVersion
impl ProtocolVersion
Sourcepub fn current() -> Self
pub fn current() -> Self
Get the current protocol version
Reads version information from environment variables set at compile time by build.rs. The semantic version is always available, while git information may be absent if the build was done without git available.
Sourcepub fn is_compatible_with(&self, other: &Self) -> bool
pub fn is_compatible_with(&self, other: &Self) -> bool
Check if this version is compatible with another version
Currently implements exact version matching: versions are compatible only if their semantic versions match exactly.
§Examples
use common::version::ProtocolVersion;
let v1 = ProtocolVersion {
semantic: "0.22.0".to_string(),
git_describe: None,
git_hash: None,
};
let v2 = ProtocolVersion {
semantic: "0.22.0".to_string(),
git_describe: Some("v0.21.1-7-g644da27".to_string()),
git_hash: None,
};
assert!(v1.is_compatible_with(&v2));Sourcepub fn display(&self) -> String
pub fn display(&self) -> String
Get a human-readable version string
Returns the semantic version, optionally including git describe information if available.
§Examples
use common::version::ProtocolVersion;
let v = ProtocolVersion {
semantic: "0.22.0".to_string(),
git_describe: Some("v0.21.1-7-g644da27".to_string()),
git_hash: None,
};
assert_eq!(v.display(), "0.22.0 (v0.21.1-7-g644da27)");Trait Implementations§
Source§impl Clone for ProtocolVersion
impl Clone for ProtocolVersion
Source§fn clone(&self) -> ProtocolVersion
fn clone(&self) -> ProtocolVersion
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ProtocolVersion
impl Debug for ProtocolVersion
Source§impl<'de> Deserialize<'de> for ProtocolVersion
impl<'de> Deserialize<'de> for ProtocolVersion
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for ProtocolVersion
impl Display for ProtocolVersion
Source§impl PartialEq for ProtocolVersion
impl PartialEq for ProtocolVersion
Source§impl Serialize for ProtocolVersion
impl Serialize for ProtocolVersion
impl Eq 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request