Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .helix/languages.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[language-server.rust-analyzer]
config = { cargo = { features = "all" } }
12 changes: 8 additions & 4 deletions src/resolv/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ pub trait Resolver {
type Answer: AsRef<Message<Self::Octets>>;

/// The future resolving into an answer.
type Query: Future<Output = Result<Self::Answer, io::Error>> + Send;
type Query<'a>: Future<Output = Result<Self::Answer, io::Error>> + Send
where
Self: 'a;

/// Returns a future answering a question.
///
/// The method takes anything that can be converted into a question and
/// produces a future trying to answer the question.
fn query<N, Q>(&self, question: Q) -> Self::Query
fn query<'a, N, Q>(&'a self, question: Q) -> Self::Query<'a>
where
N: ToName,
Q: Into<Question<N>>;
Expand All @@ -51,8 +53,10 @@ pub trait Resolver {
/// implemented via an iterator over domain names.
pub trait SearchNames {
type Name: ToName;
type Iter: Iterator<Item = Self::Name>;
type Iter<'a>: Iterator<Item = Self::Name>
where
Self: 'a;

/// Returns an iterator over the search suffixes.
fn search_iter(&self) -> Self::Iter;
fn search_iter<'a>(&'a self) -> Self::Iter<'a>;
}
29 changes: 14 additions & 15 deletions src/resolv/stub/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ impl StubResolver {
StubResolver {
transport: None.into(),
options: conf.options,

servers: conf.servers,
}
}
Expand Down Expand Up @@ -230,22 +229,22 @@ impl StubResolver {
pub async fn lookup_addr(
&self,
addr: IpAddr,
) -> Result<FoundAddrs<&Self>, io::Error> {
lookup_addr(&self, addr).await
) -> Result<FoundAddrs<Self>, io::Error> {
lookup_addr(self, addr).await
}

pub async fn lookup_host(
&self,
qname: impl ToName,
) -> Result<FoundHosts<&Self>, io::Error> {
lookup_host(&self, qname).await
) -> Result<FoundHosts<Self>, io::Error> {
lookup_host(self, qname).await
}

pub async fn search_host(
&self,
qname: impl ToRelativeName,
) -> Result<FoundHosts<&Self>, io::Error> {
search_host(&self, qname).await
) -> Result<FoundHosts<Self>, io::Error> {
search_host(self, qname).await
}

/// Performs an SRV lookup using this resolver.
Expand All @@ -257,7 +256,7 @@ impl StubResolver {
name: impl ToName,
fallback_port: u16,
) -> Result<Option<FoundSrvs>, SrvError> {
lookup_srv(&self, service, name, fallback_port).await
lookup_srv(self, service, name, fallback_port).await
}
}

Expand Down Expand Up @@ -309,13 +308,13 @@ impl Default for StubResolver {
}
}

impl<'a> Resolver for &'a StubResolver {
impl Resolver for StubResolver {
type Octets = Bytes;
type Answer = Answer;
type Query =
type Query<'a> =
Pin<Box<dyn Future<Output = Result<Answer, io::Error>> + Send + 'a>>;

fn query<N, Q>(&self, question: Q) -> Self::Query
fn query<'a, N, Q>(&'a self, question: Q) -> Self::Query<'a>
where
N: ToName,
Q: Into<Question<N>>,
Expand All @@ -325,11 +324,11 @@ impl<'a> Resolver for &'a StubResolver {
}
}

impl<'a> SearchNames for &'a StubResolver {
impl SearchNames for StubResolver {
type Name = SearchSuffix;
type Iter = SearchIter<'a>;
type Iter<'a> = SearchIter<'a>;

fn search_iter(&self) -> Self::Iter {
fn search_iter<'a>(&'a self) -> Self::Iter<'a> {
SearchIter {
resolver: self,
pos: 0,
Expand Down Expand Up @@ -420,7 +419,7 @@ impl<'a> Query<'a> {
.map_err(|e| io::Error::other(e.to_string()))?;
let mut gr_fut = transport.send_request(request_msg);
let reply =
timeout(self.resolver.options.timeout, gr_fut.get_response())
timeout(self.resolver.options().timeout, gr_fut.get_response())
.await?
.map_err(|e| io::Error::other(e.to_string()))?;
Ok(Answer { message: reply })
Expand Down