#[non_exhaustive]pub struct DocRelayFlags {
pub known: RelayFlags,
pub unknown: Unknown<HashSet<String>>,
}Expand description
Router flags (aka relay flags), including, maybe, unknown ones
§PartialEq implementation
DocRelayFlags implements PartialEq.
Two DocRelayFlags which both omit unknown flags (ie, contain Unknown::Discarded)
are treated as equal if they contain the same set of known flags.
This makes sense, because applications (like clients) that discard flags during netdoc
parsing want to completely ignore unknown flags, and want to have a working comparison
function for relay flags (eg to tell if two relays are similar enough).
Two RelayFlags only one of which retained unknown flags are treated as unequal.
Such a comparison is probably a bug, but panicking would be worse.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.known: RelayFlagsKnown flags
Invariant: contains no unknown set bits.
unknown: Unknown<HashSet<String>>Unknown flags, if they were parsed
Not sorted.
Implementations§
Source§impl DocRelayFlags
impl DocRelayFlags
Sourcepub(crate) fn from_item_consensus(
item: &Item<'_, NetstatusKwd>,
) -> Result<DocRelayFlags>
pub(crate) fn from_item_consensus( item: &Item<'_, NetstatusKwd>, ) -> Result<DocRelayFlags>
Parse a relay-flags entry from an “s” line.
Source§impl DocRelayFlags
impl DocRelayFlags
Sourcepub fn new_empty_unknown_discarded() -> Self
pub fn new_empty_unknown_discarded() -> Self
Create a new DocRelayFlags with no known flags and no information about unknown flags
Methods from Deref<Target = RelayFlags>§
Sourcepub fn is_disjoint(&self, other: EnumSet<T>) -> bool
pub fn is_disjoint(&self, other: EnumSet<T>) -> bool
Returns true if self has no elements in common with other. This is equivalent to
checking for an empty intersection.
Sourcepub fn is_superset(&self, other: EnumSet<T>) -> bool
pub fn is_superset(&self, other: EnumSet<T>) -> bool
Returns true if the set is a superset of another, i.e., self contains at least all the
values in other.
Sourcepub fn is_subset(&self, other: EnumSet<T>) -> bool
pub fn is_subset(&self, other: EnumSet<T>) -> bool
Returns true if the set is a subset of another, i.e., other contains at least all
the values in self.
Sourcepub fn union(&self, other: EnumSet<T>) -> EnumSet<T>
pub fn union(&self, other: EnumSet<T>) -> EnumSet<T>
Returns a set containing any elements present in either set.
Sourcepub fn intersection(&self, other: EnumSet<T>) -> EnumSet<T>
pub fn intersection(&self, other: EnumSet<T>) -> EnumSet<T>
Returns a set containing every element present in both sets.
Sourcepub fn difference(&self, other: EnumSet<T>) -> EnumSet<T>
pub fn difference(&self, other: EnumSet<T>) -> EnumSet<T>
Returns a set containing element present in self but not in other.
Sourcepub fn symmetrical_difference(&self, other: EnumSet<T>) -> EnumSet<T>
pub fn symmetrical_difference(&self, other: EnumSet<T>) -> EnumSet<T>
Returns a set containing every element present in either self or other, but is not
present in both.
Sourcepub fn complement(&self) -> EnumSet<T>
pub fn complement(&self) -> EnumSet<T>
Returns a set containing all enum variants not in this set.
pub const EMPTY: EnumSet<T> = Self::EMPTY_REPR
pub const ALL: EnumSet<T> = Self::ALL_REPR
Sourcepub fn as_repr(&self) -> <T as EnumSetTypeWithRepr>::Repr
pub fn as_repr(&self) -> <T as EnumSetTypeWithRepr>::Repr
Returns a T::Repr representing the elements of this set.
Unlike the other as_* methods, this method is zero-cost and guaranteed not to fail,
panic or truncate any bits.
In order to use this method, the definition of T must have an
#[enumset(repr = "…")] annotation
with a primitive integer type.
Sourcepub fn as_u8(&self) -> u8
pub fn as_u8(&self) -> u8
Returns a u8 representing the elements of this set.
If the underlying bitset will not fit in a u8, this method will panic.
Sourcepub fn try_as_u8(&self) -> Option<u8>
pub fn try_as_u8(&self) -> Option<u8>
Tries to return a u8 representing the elements of this set.
If the underlying bitset will not fit in a u8, this method will panic.
Sourcepub fn as_u8_truncated(&self) -> u8
pub fn as_u8_truncated(&self) -> u8
Returns a truncated u8 representing the elements of this set.
If the underlying bitset will not fit in a u8, this method will truncate any bits that don’t fit.
Sourcepub fn as_u16(&self) -> u16
pub fn as_u16(&self) -> u16
Returns a u16 representing the elements of this set.
If the underlying bitset will not fit in a u16, this method will panic.
Sourcepub fn try_as_u16(&self) -> Option<u16>
pub fn try_as_u16(&self) -> Option<u16>
Tries to return a u16 representing the elements of this set.
If the underlying bitset will not fit in a u16, this method will panic.
Sourcepub fn as_u16_truncated(&self) -> u16
pub fn as_u16_truncated(&self) -> u16
Returns a truncated u16 representing the elements of this set.
If the underlying bitset will not fit in a u16, this method will truncate any bits that don’t fit.
Sourcepub fn as_u32(&self) -> u32
pub fn as_u32(&self) -> u32
Returns a u32 representing the elements of this set.
If the underlying bitset will not fit in a u32, this method will panic.
Sourcepub fn try_as_u32(&self) -> Option<u32>
pub fn try_as_u32(&self) -> Option<u32>
Tries to return a u32 representing the elements of this set.
If the underlying bitset will not fit in a u32, this method will panic.
Sourcepub fn as_u32_truncated(&self) -> u32
pub fn as_u32_truncated(&self) -> u32
Returns a truncated u32 representing the elements of this set.
If the underlying bitset will not fit in a u32, this method will truncate any bits that don’t fit.
Sourcepub fn as_u64(&self) -> u64
pub fn as_u64(&self) -> u64
Returns a u64 representing the elements of this set.
If the underlying bitset will not fit in a u64, this method will panic.
Sourcepub fn try_as_u64(&self) -> Option<u64>
pub fn try_as_u64(&self) -> Option<u64>
Tries to return a u64 representing the elements of this set.
If the underlying bitset will not fit in a u64, this method will panic.
Sourcepub fn as_u64_truncated(&self) -> u64
pub fn as_u64_truncated(&self) -> u64
Returns a truncated u64 representing the elements of this set.
If the underlying bitset will not fit in a u64, this method will truncate any bits that don’t fit.
Sourcepub fn as_u128(&self) -> u128
pub fn as_u128(&self) -> u128
Returns a u128 representing the elements of this set.
If the underlying bitset will not fit in a u128, this method will panic.
Sourcepub fn try_as_u128(&self) -> Option<u128>
pub fn try_as_u128(&self) -> Option<u128>
Tries to return a u128 representing the elements of this set.
If the underlying bitset will not fit in a u128, this method will panic.
Sourcepub fn as_u128_truncated(&self) -> u128
pub fn as_u128_truncated(&self) -> u128
Returns a truncated u128 representing the elements of this set.
If the underlying bitset will not fit in a u128, this method will truncate any bits that don’t fit.
Sourcepub fn as_usize(&self) -> usize
pub fn as_usize(&self) -> usize
Returns a usize representing the elements of this set.
If the underlying bitset will not fit in a usize, this method will panic.
Sourcepub fn try_as_usize(&self) -> Option<usize>
pub fn try_as_usize(&self) -> Option<usize>
Tries to return a usize representing the elements of this set.
If the underlying bitset will not fit in a usize, this method will panic.
Sourcepub fn as_usize_truncated(&self) -> usize
pub fn as_usize_truncated(&self) -> usize
Returns a truncated usize representing the elements of this set.
If the underlying bitset will not fit in a usize, this method will truncate any bits that don’t fit.
Sourcepub fn as_array<const O: usize>(&self) -> [u64; O]
pub fn as_array<const O: usize>(&self) -> [u64; O]
Returns an [u64; O] representing the elements of this set.
If the underlying bitset will not fit in a [u64; O], this method will panic.
Sourcepub fn try_as_array<const O: usize>(&self) -> Option<[u64; O]>
pub fn try_as_array<const O: usize>(&self) -> Option<[u64; O]>
Returns an [u64; O] representing the elements of this set.
If the underlying bitset will not fit in a [u64; O], this method will instead return
None.
Sourcepub fn as_array_truncated<const O: usize>(&self) -> [u64; O]
pub fn as_array_truncated<const O: usize>(&self) -> [u64; O]
Returns an [u64; O] representing the elements of this set.
If the underlying bitset will not fit in a [u64; O], this method will truncate any bits
that don’t fit.
Sourcepub fn copy_into_slice(&self, data: &mut [u64])
pub fn copy_into_slice(&self, data: &mut [u64])
Copies the elements of this set into a &mut [u64].
If the underlying bitset will not fit in the provided slice, this method will panic.
Sourcepub fn try_copy_into_slice(&self, data: &mut [u64]) -> Option<()>
pub fn try_copy_into_slice(&self, data: &mut [u64]) -> Option<()>
Copies the elements of this set into a &mut [u64].
If the underlying bitset will not fit in the provided slice, this method will return
None. Otherwise, it will return Some(()).
Sourcepub fn copy_into_slice_truncated(&self, data: &mut [u64])
pub fn copy_into_slice_truncated(&self, data: &mut [u64])
Copies the elements of this set into a &mut [u64].
If the underlying bitset will not fit in the provided slice, this method will truncate any bits that don’t fit.
Sourcepub fn iter(&self) -> EnumSetIter<T>
pub fn iter(&self) -> EnumSetIter<T>
Iterates the contents of the set in order from the least significant bit to the most significant bit.
Note that iterator invalidation is impossible as the iterator contains a copy of this type, rather than holding a reference to it.
Trait Implementations§
Source§impl Clone for DocRelayFlags
impl Clone for DocRelayFlags
Source§fn clone(&self) -> DocRelayFlags
fn clone(&self) -> DocRelayFlags
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 DocRelayFlags
impl Debug for DocRelayFlags
Source§impl Deref for DocRelayFlags
impl Deref for DocRelayFlags
Source§impl PartialEq for DocRelayFlags
impl PartialEq for DocRelayFlags
Source§fn eq(&self, other: &DocRelayFlags) -> bool
fn eq(&self, other: &DocRelayFlags) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for DocRelayFlags
Auto Trait Implementations§
impl Freeze for DocRelayFlags
impl RefUnwindSafe for DocRelayFlags
impl Send for DocRelayFlags
impl Sync for DocRelayFlags
impl Unpin for DocRelayFlags
impl UnsafeUnpin for DocRelayFlags
impl UnwindSafe for DocRelayFlags
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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 more