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,
) -> AddrFilter
pub fn new( f: impl Fn(&Vec<TransportAddr>) -> Cow<'_, Vec<TransportAddr>> + Send + Sync + 'static, ) -> AddrFilter
Create a new AddrFilter
Sourcepub fn unfiltered() -> AddrFilter
pub fn unfiltered() -> AddrFilter
Constructs a filter that doesn’t filter addresses and passes all through.
Sourcepub fn relay_only() -> AddrFilter
pub fn relay_only() -> AddrFilter
Only keep relay addresses.
Sourcepub fn ip_only() -> AddrFilter
pub fn ip_only() -> AddrFilter
Only keep direct IP 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
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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
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§
§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> 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