pub struct Finder { /* private fields */ }Expand description
Asks every source for a target, at the same time, and merges the answers.
An IP address goes to RDAP and Abusix. A domain name goes to RDAP, abuse.net and RFC 2142.
The finder holds the RDAP answers in a Cache, so it does not ask a registry
about the same network or the same domain again. Finder::with_cache sets how
long an answer is held.
use abuse_contact::{Client, Finder, Resolver};
let finder = Finder::new(Client::new().await?, Resolver::new()?);
let found = finder.lookup("196.216.2.1".parse::<std::net::IpAddr>().unwrap()).await?;
for contact in &found.contacts {
println!("{} ({:?})", contact.email, contact.scope);
}
for failure in &found.failures {
eprintln!("{failure}");
}Implementations§
Source§impl Finder
impl Finder
Sourcepub fn new(client: Client, resolver: Resolver) -> Self
pub fn new(client: Client, resolver: Resolver) -> Self
Returns a finder that asks RDAP with this client and DNS with this resolver.
It holds the RDAP answers in Cache::default.
Sourcepub fn with_cache(self, cache: Cache) -> Self
pub fn with_cache(self, cache: Cache) -> Self
Returns the finder with the RDAP answers held in this cache.
Keep a clone of the cache to read its size or to clear it.
Sourcepub async fn lookup(&self, query: impl Into<Query>) -> Result<Found, Error>
pub async fn lookup(&self, query: impl Into<Query>) -> Result<Found, Error>
Asks every source for the target and returns what they found.
A source that fails does not fail the lookup. Its error is in
Found::failures, and the contacts from the other sources are still given.
§Errors
Returns Error::NotPublic for a private or reserved address. No source is
asked for it.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Finder
impl !UnwindSafe for Finder
impl Freeze for Finder
impl Send for Finder
impl Sync for Finder
impl Unpin for Finder
impl UnsafeUnpin for Finder
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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