pub struct CapabilitySet(/* private fields */);Expand description
A set of capabilities agreed between two peers.
Thin wrapper around BTreeSet<Capability> whose only job is to
name the CapabilitySet::intersect operation that both clients
and servers perform on handshake: each side advertises the
capabilities it supports, and the intersection is the set both
agree to use for the rest of the session.
This type stays pure-data (no network, no HTTP) so both
mnem http and mnem-transport::client can consume it.
Implementations§
Source§impl CapabilitySet
impl CapabilitySet
Sourcepub fn with_caps<I: IntoIterator<Item = Capability>>(caps: I) -> Self
pub fn with_caps<I: IntoIterator<Item = Capability>>(caps: I) -> Self
Build from any capability iterator. Duplicates are collapsed.
Sourcepub fn all_known() -> Self
pub fn all_known() -> Self
Every capability this build knows about. Equivalent to
with_caps(Capability::all().iter().copied()) but allocates
once rather than walking a slice.
Sourcepub fn parse(s: &str) -> Self
pub fn parse(s: &str) -> Self
Parse from the comma-separated wire form; unknown entries are
dropped (forward-compat, same rule as parse_capabilities).
Sourcepub fn intersect(&self, other: &Self) -> Self
pub fn intersect(&self, other: &Self) -> Self
Capability intersection: the set of capabilities both peers advertised. This is the agreed-upon feature set for the remainder of the session.
intersect(A, B) = { c | c in A and c in B }Sourcepub fn contains(&self, cap: Capability) -> bool
pub fn contains(&self, cap: Capability) -> bool
True if the given capability is in this set.
Sourcepub const fn as_set(&self) -> &BTreeSet<Capability>
pub const fn as_set(&self) -> &BTreeSet<Capability>
Borrow the underlying sorted set.
Trait Implementations§
Source§impl Clone for CapabilitySet
impl Clone for CapabilitySet
Source§fn clone(&self) -> CapabilitySet
fn clone(&self) -> CapabilitySet
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CapabilitySet
impl Debug for CapabilitySet
Source§impl Default for CapabilitySet
impl Default for CapabilitySet
Source§fn default() -> CapabilitySet
fn default() -> CapabilitySet
Source§impl From<BTreeSet<Capability>> for CapabilitySet
impl From<BTreeSet<Capability>> for CapabilitySet
Source§fn from(s: BTreeSet<Capability>) -> Self
fn from(s: BTreeSet<Capability>) -> Self
Source§impl PartialEq for CapabilitySet
impl PartialEq for CapabilitySet
Source§fn eq(&self, other: &CapabilitySet) -> bool
fn eq(&self, other: &CapabilitySet) -> bool
self and other values to be equal, and is used by ==.