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
raw: StringExactly 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
impl PeerSoftware
Sourcepub fn parse(advertised: &str) -> Self
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
impl Clone for PeerSoftware
Source§fn clone(&self) -> PeerSoftware
fn clone(&self) -> PeerSoftware
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more