pub struct WeightedSet<'a> { /* private fields */ }
Expand description
A structure that represents a set of addresses of the same priority
Implementations§
Source§impl<'a> WeightedSet<'a>
impl<'a> WeightedSet<'a>
Sourcepub fn pick_one(&self) -> Option<SocketAddr>
pub fn pick_one(&self) -> Option<SocketAddr>
Select one random address to connect to
This function selects a host according to the random distribution according to the weights.
Returns None
if the set is empty
Sourcepub fn addresses(&self) -> AddressIter<'_> ⓘ
pub fn addresses(&self) -> AddressIter<'_> ⓘ
Returns iterator over underlying addresses
This effectively discards weights, but may be useful for cases where
you treat addresses as a set. For example to find out whether two
Address
values intersect over SocketAddr
.
Sourcepub fn compare_addresses(
&self,
other: &WeightedSet<'_>,
) -> (Vec<SocketAddr>, Vec<SocketAddr>)
pub fn compare_addresses( &self, other: &WeightedSet<'_>, ) -> (Vec<SocketAddr>, Vec<SocketAddr>)
Compares two weighted sets to find out which addresses have been removed from set or added
This doesn’t compare weights of the addresses
Trait Implementations§
Source§impl<'a> Debug for WeightedSet<'a>
impl<'a> Debug for WeightedSet<'a>
Source§impl<'a> PartialEq for WeightedSet<'a>
impl<'a> PartialEq for WeightedSet<'a>
Auto Trait Implementations§
impl<'a> Freeze for WeightedSet<'a>
impl<'a> RefUnwindSafe for WeightedSet<'a>
impl<'a> Send for WeightedSet<'a>
impl<'a> Sync for WeightedSet<'a>
impl<'a> Unpin for WeightedSet<'a>
impl<'a> UnwindSafe for WeightedSet<'a>
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