Struct tor_netdir::RelayWeight
source · pub struct RelayWeight(/* private fields */);
Expand description
An opaque type representing the weight with which a relay or set of relays will be selected for a given role.
Most users should ignore this type, and just use pick_relay instead.
Implementations§
source§impl RelayWeight
impl RelayWeight
sourcepub fn checked_div(&self, rhs: RelayWeight) -> Option<f64>
pub fn checked_div(&self, rhs: RelayWeight) -> Option<f64>
Try to divide this weight by rhs
.
Return a ratio on success, or None on division-by-zero.
sourcepub fn ratio(&self, frac: f64) -> Option<RelayWeight>
pub fn ratio(&self, frac: f64) -> Option<RelayWeight>
Compute a ratio frac
of this weight.
Return None if frac is less than zero, since negative weights are impossible.
Trait Implementations§
source§impl Add for RelayWeight
impl Add for RelayWeight
§type Output = RelayWeight
type Output = RelayWeight
The resulting type after applying the
+
operator.source§fn add(self, rhs: RelayWeight) -> RelayWeight
fn add(self, rhs: RelayWeight) -> RelayWeight
Performs the
+
operation. Read moresource§impl AddAssign for RelayWeight
impl AddAssign for RelayWeight
source§fn add_assign(&mut self, rhs: RelayWeight)
fn add_assign(&mut self, rhs: RelayWeight)
Performs the
+=
operation. Read moresource§impl Clone for RelayWeight
impl Clone for RelayWeight
source§fn clone(&self) -> RelayWeight
fn clone(&self) -> RelayWeight
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for RelayWeight
impl Debug for RelayWeight
source§impl From<u64> for RelayWeight
impl From<u64> for RelayWeight
source§impl Ord for RelayWeight
impl Ord for RelayWeight
source§fn cmp(&self, other: &RelayWeight) -> Ordering
fn cmp(&self, other: &RelayWeight) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for RelayWeight
impl PartialEq for RelayWeight
source§fn eq(&self, other: &RelayWeight) -> bool
fn eq(&self, other: &RelayWeight) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for RelayWeight
impl PartialOrd for RelayWeight
source§fn partial_cmp(&self, other: &RelayWeight) -> Option<Ordering>
fn partial_cmp(&self, other: &RelayWeight) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl Sum for RelayWeight
impl Sum for RelayWeight
impl Copy for RelayWeight
impl Eq for RelayWeight
impl StructuralPartialEq for RelayWeight
Auto Trait Implementations§
impl Freeze for RelayWeight
impl RefUnwindSafe for RelayWeight
impl Send for RelayWeight
impl Sync for RelayWeight
impl Unpin for RelayWeight
impl UnwindSafe for RelayWeight
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.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>
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 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>
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