Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiaddr: feature gate url dependency #1843

Merged
merged 2 commits into from
Nov 17, 2020
Merged
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
5 changes: 4 additions & 1 deletion misc/multiaddr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ keywords = ["multiaddr", "ipfs"]
license = "MIT"
version = "0.9.5"

[features]
default = ["url"]

[dependencies]
arrayref = "0.3"
bs58 = "0.4.0"
Expand All @@ -18,7 +21,7 @@ percent-encoding = "2.1.0"
serde = "1.0.70"
static_assertions = "1.1"
unsigned-varint = "0.5"
url = { version = "2.1.0", default-features = false }
url = { version = "2.1.0", optional = true, default-features = false }

[dev-dependencies]
bincode = "1"
Expand Down
6 changes: 6 additions & 0 deletions misc/multiaddr/src/from_url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ use std::{error, fmt, iter, net::IpAddr};
/// generated multiaddress. This includes a username, password, path (if not supported by the
/// multiaddr), and query string.
///
/// This function is only present if the `url` feature is enabled, and it is
/// enabled by default.
///
/// The supported URL schemes are:
///
/// - `ws://example.com/`
Expand All @@ -31,6 +34,9 @@ pub fn from_url(url: &str) -> std::result::Result<Multiaddr, FromUrlErr> {
/// This function is similar to [`from_url`], except that we don't return an error if some
/// information in the URL cannot be retain in the generated multiaddres.
///
/// This function is only present if the `url` feature is enabled, and it is
/// enabled by default.
///
/// # Example
///
/// ```
Expand Down
6 changes: 5 additions & 1 deletion misc/multiaddr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ pub use multihash;
mod protocol;
mod onion_addr;
mod errors;

#[cfg(feature = "url")]
mod from_url;

use serde::{
Expand All @@ -25,10 +27,12 @@ use std::{
sync::Arc
};
pub use self::errors::{Result, Error};
pub use self::from_url::{FromUrlErr, from_url, from_url_lossy};
pub use self::protocol::Protocol;
pub use self::onion_addr::Onion3Addr;

#[cfg(feature = "url")]
pub use self::from_url::{FromUrlErr, from_url, from_url_lossy};

static_assertions::const_assert! {
// This check is most certainly overkill right now, but done here
// anyway to ensure the `as u64` casts in this crate are safe.
Expand Down