pub struct AddrFilter(/* private fields */);Expand description
A filter and/or reordering function applied to transport addresses, typically used by AddressLookup services in iroh before publishing.
Takes the full set of transport addresses and returns them as an ordered Vec,
allowing both filtering (by omitting addresses) and reordering (by controlling
the output order). A BTreeSet cannot preserve a custom order, so the return
type is Vec to make reordering possible.
See the documentation for each address lookup implementation for details on what additional filtering the implementation may perform on top.
Implementations§
Source§impl AddrFilter
impl AddrFilter
Sourcepub fn new(
f: impl Fn(&Vec<TransportAddr>) -> Cow<'_, Vec<TransportAddr>> + Send + Sync + 'static,
) -> Self
pub fn new( f: impl Fn(&Vec<TransportAddr>) -> Cow<'_, Vec<TransportAddr>> + Send + Sync + 'static, ) -> Self
Create a new AddrFilter
Sourcepub fn unfiltered() -> Self
pub fn unfiltered() -> Self
Constructs a filter that doesn’t filter addresses and passes all through.
Sourcepub fn relay_only() -> Self
pub fn relay_only() -> Self
Only keep relay addresses.
Sourcepub fn apply<'a>(
&self,
addrs: &'a Vec<TransportAddr>,
) -> Cow<'a, Vec<TransportAddr>>
pub fn apply<'a>( &self, addrs: &'a Vec<TransportAddr>, ) -> Cow<'a, Vec<TransportAddr>>
Apply the address filter function to a set of addresses.
Trait Implementations§
Source§impl Clone for AddrFilter
impl Clone for AddrFilter
Source§fn clone(&self) -> AddrFilter
fn clone(&self) -> AddrFilter
Returns a duplicate 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 AddrFilter
impl Debug for AddrFilter
Source§impl Default for AddrFilter
impl Default for AddrFilter
Source§fn default() -> AddrFilter
fn default() -> AddrFilter
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for AddrFilter
impl !RefUnwindSafe for AddrFilter
impl Send for AddrFilter
impl Sync for AddrFilter
impl Unpin for AddrFilter
impl !UnwindSafe for AddrFilter
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