pub struct SubprotocolDescriptor {
pub id: u16,
pub name: String,
pub version: SubprotocolVersion,
pub min_compatible: SubprotocolVersion,
pub handler_present: bool,
}Expand description
Metadata describing a registered subprotocol.
Fields§
§id: u16Unique protocol ID (from Net header subprotocol_id field).
name: StringHuman-readable name (e.g., “causal”, “migration”, “vendor-x-inference”).
version: SubprotocolVersionVersion of this handler.
min_compatible: SubprotocolVersionMinimum compatible version accepted from peers.
handler_present: boolWhether this node can process packets for this subprotocol (false = opaque forwarding only, no local handler).
Implementations§
Source§impl SubprotocolDescriptor
impl SubprotocolDescriptor
Sourcepub fn new(
id: u16,
name: impl Into<String>,
version: SubprotocolVersion,
) -> Self
pub fn new( id: u16, name: impl Into<String>, version: SubprotocolVersion, ) -> Self
Create a new descriptor.
Sourcepub fn with_min_compatible(self, min: SubprotocolVersion) -> Self
pub fn with_min_compatible(self, min: SubprotocolVersion) -> Self
Set the minimum compatible version.
Enforces the wire-format invariant
min_compatible <= version. Allowing
min_compatible > version would break
is_compatible_with’s contract — every honest peer
computes local.version.satisfies(other.min_compatible),
which silently fails for any version of local once
other.min_compatible > other.version. On the wire-format
side that enables a phantom-incompatibility DoS where a
peer advertises min_compatible=255.255 against
version=1.0 and unilaterally evicts the subprotocol from
negotiation. The constructor (new) initializes
min_compatible = version so the invariant holds by
default; this setter clamps min to self.version if a
caller passes a higher value.
Sourcepub fn forwarding_only(self) -> Self
pub fn forwarding_only(self) -> Self
Mark as forwarding-only (no local handler).
Sourcepub fn is_compatible_with(&self, other: &Self) -> bool
pub fn is_compatible_with(&self, other: &Self) -> bool
Check if two descriptors are version-compatible.
Both sides must satisfy the other’s minimum requirement.
Sourcepub fn capability_tag(&self) -> String
pub fn capability_tag(&self) -> String
Capability tag for this subprotocol (e.g., “subprotocol:0x0400”).
Trait Implementations§
Source§impl Clone for SubprotocolDescriptor
impl Clone for SubprotocolDescriptor
Source§fn clone(&self) -> SubprotocolDescriptor
fn clone(&self) -> SubprotocolDescriptor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more