Skip to main content

PeerSoftware

Enum PeerSoftware 

Source
pub enum PeerSoftware {
    Unknown,
    Reported {
        product: String,
        version: Version,
        raw: String,
    },
}
Expand description

A peer’s advertised SOFTWARE build, as read from the gossip handshake (dig_ecosystem#2215).

dig-gossip carries the peer’s Handshake.software_version as an opaque sanitized string and deliberately does not interpret it. This type is where that string becomes meaning, once, at the control boundary — so the interpretation is defined in one place and every client agrees.

§This is NOT the protocol version

Wire compatibility is a separate field that dig-gossip gates connections on. Two peers can speak the same protocol while running builds months apart; this type reports the latter. It MUST NOT be used to decide whether to talk to a peer.

§Why there is no Ord and no Default

Unknown has no position on a version line: it is the absence of a measurement, not a low value. Deriving Ord would place it somewhere — and every peer built before #2215 is Unknown, so “somewhere” would silently become a verdict about most of the live network. Comparison is therefore reachable only by destructuring Reported, which forces the caller to say what Unknown means for their question. There is no Default for the same reason: a defaulted Unknown that appears from nowhere is a different fact from one that was measured, and the two must not be confusable.

§JSON

{"kind": "unknown"}
{"kind": "reported", "product": "dig-node", "version": "0.99.1", "raw": "dig-node/0.99.1"}

Unknown carries no version member at all — never version zero, never "", never null in a field a consumer might read as a version.

Variants§

§

Unknown

The peer’s build is not known: it advertised nothing, advertised VERSION ZERO — the legacy sentinel, in any decoration (0.0.0, 0.0.0-rc.1, 0.0.0+build) — or advertised something this contract cannot parse. See PeerSoftware::parse for why those three are one case.

§

Reported

The peer advertised a well-formed product/semver build.

Fields

§product: String

The product name, e.g. dig-node. Everything before the LAST /.

§version: Version

The parsed semantic version, e.g. 0.99.1. Serializes as its string form.

§raw: String

Exactly what the peer advertised, after trimming.

Currently reconstructible, deliberately kept. The grammar this parser accepts is lossless — semver::Version re-renders every string it accepts byte-identically — so today raw always equals format!("{product}/{version}"), and no test can distinguish this field from that expression. It is retained as the honest source: the moment the grammar accepts anything non-canonical (a v prefix, a two-part version, a vendor suffix), a diagnostic reader must see what the peer actually sent rather than this parser’s opinion of it, and callers that already read raw will not need to change.

Implementations§

Source§

impl PeerSoftware

Source

pub fn parse(advertised: &str) -> Self

Interpret a peer’s advertised software_version string.

Returns Unknown for an empty or blank string, for anything that is not product/semver with both parts non-empty and the version parsing as semver, and for any advertisement whose version is VERSION ZERO.

Version zero is the legacy sentinel and is matched as a CLASS, not as a string: the bare 0.0.0, a product-qualified dig-node/0.0.0, and every decorated form (0.0.0-rc.1, 0.0.0+build, 0.0.0-0) all mean “unversioned”. A peer advertising 0.0.0-rc.1 is no more versioned than one advertising 0.0.0.

A product name may contain /; the split is at the LAST separator.

Trait Implementations§

Source§

impl Clone for PeerSoftware

Source§

fn clone(&self) -> PeerSoftware

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PeerSoftware

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for PeerSoftware

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for PeerSoftware

Source§

impl PartialEq for PeerSoftware

Source§

fn eq(&self, other: &PeerSoftware) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for PeerSoftware

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for PeerSoftware

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.