pub struct CapabilityRegistry { /* private fields */ }Expand description
Per-node registry that owns capability instances, generates the local advertisement, and stores the most recently negotiated value for each capability.
Implementations§
Source§impl CapabilityRegistry
impl CapabilityRegistry
Sourcepub fn register<C: Capability>(&mut self, cap: C)
pub fn register<C: Capability>(&mut self, cap: C)
Register a capability. Re-registering a capability with the same name replaces the previous entry; the cluster layer never registers two caps with the same name, so this only matters for tests.
Sourcepub fn local_advertise(&self) -> CapabilityAd
pub fn local_advertise(&self) -> CapabilityAd
Build the advertisement to ship to peers.
Sourcepub fn negotiate(&self, peer_ad: &CapabilityAd) -> NegotiatedCapabilities
pub fn negotiate(&self, peer_ad: &CapabilityAd) -> NegotiatedCapabilities
Resolve peer_ad against the locally registered caps.
Returns a NegotiatedCapabilities keyed by capability
name. The registry also caches each negotiated value so
later calls to CapabilityRegistry::current reflect the
most recent negotiation.
Capabilities present in peer_ad but not registered
locally fall through silently: the negotiator can only
pick a value for capabilities both sides know about.
Sourcepub fn current<C: Capability>(&self, name: &str) -> Option<C::Value>
pub fn current<C: Capability>(&self, name: &str) -> Option<C::Value>
Return the currently active value for the named
capability, decoded with the registered cap’s
Capability::decode_value.
Returns None when no capability with that name is
registered, when the type parameter C does not match
the registered cap, or when the stored bytes fail to
decode (which would be a registry bug).
Before any negotiation has happened the floor value (lowest-preference local value) is returned.