diff --git a/.helix/languages.toml b/.helix/languages.toml new file mode 100644 index 000000000..6451cbf4c --- /dev/null +++ b/.helix/languages.toml @@ -0,0 +1,2 @@ +[language-server.rust-analyzer] +config = { cargo = { features = "all" } } diff --git a/src/resolv/resolver.rs b/src/resolv/resolver.rs index cf0717a42..b1bb61df9 100644 --- a/src/resolv/resolver.rs +++ b/src/resolv/resolver.rs @@ -27,13 +27,15 @@ pub trait Resolver { type Answer: AsRef>; /// The future resolving into an answer. - type Query: Future> + Send; + type Query<'a>: Future> + 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(&self, question: Q) -> Self::Query + fn query<'a, N, Q>(&'a self, question: Q) -> Self::Query<'a> where N: ToName, Q: Into>; @@ -51,8 +53,10 @@ pub trait Resolver { /// implemented via an iterator over domain names. pub trait SearchNames { type Name: ToName; - type Iter: Iterator; + type Iter<'a>: Iterator + 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>; } diff --git a/src/resolv/stub/mod.rs b/src/resolv/stub/mod.rs index a41484517..29ee95827 100644 --- a/src/resolv/stub/mod.rs +++ b/src/resolv/stub/mod.rs @@ -94,7 +94,6 @@ impl StubResolver { StubResolver { transport: None.into(), options: conf.options, - servers: conf.servers, } } @@ -230,22 +229,22 @@ impl StubResolver { pub async fn lookup_addr( &self, addr: IpAddr, - ) -> Result, io::Error> { - lookup_addr(&self, addr).await + ) -> Result, io::Error> { + lookup_addr(self, addr).await } pub async fn lookup_host( &self, qname: impl ToName, - ) -> Result, io::Error> { - lookup_host(&self, qname).await + ) -> Result, io::Error> { + lookup_host(self, qname).await } pub async fn search_host( &self, qname: impl ToRelativeName, - ) -> Result, io::Error> { - search_host(&self, qname).await + ) -> Result, io::Error> { + search_host(self, qname).await } /// Performs an SRV lookup using this resolver. @@ -257,7 +256,7 @@ impl StubResolver { name: impl ToName, fallback_port: u16, ) -> Result, SrvError> { - lookup_srv(&self, service, name, fallback_port).await + lookup_srv(self, service, name, fallback_port).await } } @@ -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> + Send + 'a>>; - fn query(&self, question: Q) -> Self::Query + fn query<'a, N, Q>(&'a self, question: Q) -> Self::Query<'a> where N: ToName, Q: Into>, @@ -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, @@ -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 })