Skip to main content

DocRelayFlags

Struct DocRelayFlags 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§known: RelayFlags

Known flags

Invariant: contains no unknown set bits.

§unknown: Unknown<HashSet<String>>

Unknown flags, if they were parsed

Not sorted.

Implementations§

Source§

impl DocRelayFlags

Source

pub(crate) fn from_item_consensus( item: &Item<'_, NetstatusKwd>, ) -> Result<DocRelayFlags>

Parse a relay-flags entry from an “s” line.

Source§

impl DocRelayFlags

Source

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>§

Source

pub fn len(&self) -> usize

Returns the number of elements in this set.

Source

pub fn is_empty(&self) -> bool

Returns true if the set contains no elements.

Source

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.

Source

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.

Source

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.

Source

pub fn union(&self, other: EnumSet<T>) -> EnumSet<T>

Returns a set containing any elements present in either set.

Source

pub fn intersection(&self, other: EnumSet<T>) -> EnumSet<T>

Returns a set containing every element present in both sets.

Source

pub fn difference(&self, other: EnumSet<T>) -> EnumSet<T>

Returns a set containing element present in self but not in other.

Source

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.

Source

pub fn complement(&self) -> EnumSet<T>

Returns a set containing all enum variants not in this set.

Source

pub fn contains(&self, value: T) -> bool

Checks whether this set contains a value.

Source

pub const EMPTY: EnumSet<T> = Self::EMPTY_REPR

Source

pub const ALL: EnumSet<T> = Self::ALL_REPR

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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(()).

Source

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.

Source

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

Source§

fn clone(&self) -> DocRelayFlags

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DocRelayFlags

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for DocRelayFlags

Source§

type Target = EnumSet<RelayFlag>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl PartialEq for DocRelayFlags

Source§

fn eq(&self, other: &DocRelayFlags) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for DocRelayFlags

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &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
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PossiblyOption<T> for T

Source§

fn to_option(self) -> Option<T>

Convert this object into an Option<T>
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more