pub struct SubnetConfig {
pub(crate) subnets_family_v4: u8,
pub(crate) subnets_family_v6: u8,
}
Expand description
Configuration for determining when two relays have addresses “too close” in the network.
Used by [Relay::low_level_details().in_same_subnet()
].
Fields§
§subnets_family_v4: u8
Consider IPv4 nodes in the same /x to be the same family.
If this value is 0, all nodes with IPv4 addresses will be in the same family. If this value is above 32, then no nodes will be placed im the same family based on their IPv4 addresses.
subnets_family_v6: u8
Consider IPv6 nodes in the same /x to be the same family.
If this value is 0, all nodes with IPv6 addresses will be in the same family. If this value is above 128, then no nodes will be placed im the same family based on their IPv6 addresses.
Implementations§
Source§impl SubnetConfig
impl SubnetConfig
Sourcepub fn new(subnets_family_v4: u8, subnets_family_v6: u8) -> Self
pub fn new(subnets_family_v4: u8, subnets_family_v6: u8) -> Self
Construct a new SubnetConfig from a pair of bit prefix lengths.
The values are clamped to the appropriate ranges if they are out-of-bounds.
Sourcepub fn no_addresses_match() -> SubnetConfig
pub fn no_addresses_match() -> SubnetConfig
Construct a new SubnetConfig such that addresses are not in the same family with anything–not even with themselves.
Sourcepub fn addrs_in_same_subnet(&self, a: &IpAddr, b: &IpAddr) -> bool
pub fn addrs_in_same_subnet(&self, a: &IpAddr, b: &IpAddr) -> bool
Return true if the two addresses in the same subnet, according to this configuration.
Sourcepub fn any_addrs_in_same_subnet<T, U>(&self, a: &T, b: &U) -> bool
pub fn any_addrs_in_same_subnet<T, U>(&self, a: &T, b: &U) -> bool
Return true if any of the addresses in a
shares a subnet with any of
the addresses in b
, according to this configuration.
Trait Implementations§
Source§impl Clone for SubnetConfig
impl Clone for SubnetConfig
Source§fn clone(&self) -> SubnetConfig
fn clone(&self) -> SubnetConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for SubnetConfig
impl Debug for SubnetConfig
Source§impl Default for SubnetConfig
impl Default for SubnetConfig
Source§impl<'de> Deserialize<'de> for SubnetConfig
impl<'de> Deserialize<'de> for SubnetConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for SubnetConfig
impl PartialEq for SubnetConfig
impl Copy for SubnetConfig
impl Eq for SubnetConfig
impl StructuralPartialEq for SubnetConfig
Auto Trait Implementations§
impl Freeze for SubnetConfig
impl RefUnwindSafe for SubnetConfig
impl Send for SubnetConfig
impl Sync for SubnetConfig
impl Unpin for SubnetConfig
impl UnwindSafe for SubnetConfig
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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
.§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
.§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.§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.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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