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.
Trait Implementations§
Source§impl Debug for CapabilityRegistry
impl Debug for CapabilityRegistry
Auto Trait Implementations§
impl !Freeze for CapabilityRegistry
impl !RefUnwindSafe for CapabilityRegistry
impl Send for CapabilityRegistry
impl Sync for CapabilityRegistry
impl Unpin for CapabilityRegistry
impl UnsafeUnpin for CapabilityRegistry
impl !UnwindSafe for CapabilityRegistry
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.