Skip to content

Commit

Permalink
Move FoundSrvs::into_stream into feature "stream"
Browse files Browse the repository at this point in the history
This function (and only this function) depends on the `futures` create,
which itself requires over a dozen other dependencies.

Move the function into its own feature, "stream". This allows enabling
the "resolv" feature without the `futures` dependency tree, which
substantially reduces unnecessary dependencies.
  • Loading branch information
WhyNotHugo committed Dec 5, 2023
1 parent 8ed1e43 commit 141ddef
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ default = ["std", "rand"]
bytes = ["dep:bytes", "octseq/bytes"]
heapless = ["dep:heapless", "octseq/heapless"]
interop = ["bytes", "ring"]
resolv = ["bytes", "futures", "smallvec", "std", "tokio", "libc", "rand"]
resolv = ["bytes", "smallvec", "std", "tokio", "libc", "rand"]
resolv-sync = ["resolv", "tokio/rt"]
serde = ["dep:serde", "octseq/serde"]
sign = ["std"]
smallvec = ["dep:smallvec", "octseq/smallvec"]
std = []
stream = ["futures"]
tsig = ["bytes", "ring", "smallvec"]
validate = ["std", "ring"]
zonefile = ["bytes", "std"]
Expand Down
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

Breaking changes

* The `FoundSrvs::into_stream` function now requires enabling the `stream`
feature.

New

Bug fixes
Expand Down
6 changes: 4 additions & 2 deletions src/resolv/lookup/srv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ use crate::base::wire::ParseError;
use crate::rdata::{Aaaa, Srv, A};
use crate::resolv::resolver::Resolver;
use core::fmt;
use futures::stream;
use futures::stream::{Stream, StreamExt};
use octseq::octets::Octets;
use rand::distributions::{Distribution, Uniform};
use std::net::{IpAddr, SocketAddr};
use std::vec::Vec;
use std::{io, mem, ops};

#[cfg(feature = "stream")]
use futures::stream::{self, Stream, StreamExt};

// Look up SRV record. Three outcomes:
//
// * at least one SRV record with a regular target,
Expand Down Expand Up @@ -101,6 +102,7 @@ impl FoundSrvs {
/// pass in a double reference since [`Resolver`] is implemented for a
/// reference to it and this method requires a reference to that impl
/// being passed. This quirk will be fixed in future versions.
#[cfg(feature = "stream")]
pub fn into_stream<R: Resolver>(
self,
resolver: &R,
Expand Down

0 comments on commit 141ddef

Please sign in to comment.