pub struct CapabilitySet { /* private fields */ }Expand description
A set of advertised capabilities.
A u128 bitset, so contains is a mask and a test rather
than a search. This matters because resolve asks
roughly thirty questions of two sets, and a session asks
FeatureProfile::allows on every
message.
Implementations§
Source§impl CapabilitySet
impl CapabilitySet
Sourcepub fn all() -> Self
pub fn all() -> Self
Every capability, on both sides. A superset of anything real, and mostly useful in tests and in the “what could this peer possibly do” query.
Sourcepub fn all_for(version: ProtocolVersion) -> Self
pub fn all_for(version: ProtocolVersion) -> Self
Every capability version defines, on both sides.
The “all capabilities on” case for a golden test, scoped to one revision so the result is something a peer could actually have sent.
Sourcepub fn with(self, capability: Capability) -> Self
pub fn with(self, capability: Capability) -> Self
Adds a capability, returning the new set.
By value rather than &mut self so that building a set in an
expression does not need a mutable binding, which is what every caller
ends up writing.
Sourcepub fn insert(&mut self, capability: Capability)
pub fn insert(&mut self, capability: Capability)
Adds a capability in place.
Sourcepub fn contains(self, capability: Capability) -> bool
pub fn contains(self, capability: Capability) -> bool
Whether the capability is in the set.
Sourcepub fn iter(self) -> impl Iterator<Item = Capability>
pub fn iter(self) -> impl Iterator<Item = Capability>
The capabilities in the set, in declaration order.
Sourcepub fn restricted_to(self, version: ProtocolVersion) -> Self
pub fn restricted_to(self, version: ProtocolVersion) -> Self
Drops every capability version does not define.
A peer cannot advertise a flag its own revision’s schema has no field for, and a flag that survives the round trip from a newer peer into an older profile is exactly the “confident wrong” the crate exists to avoid. An unknown revision therefore reduces the set to empty.