mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-05-30 03:01:21 +00:00
multiaddr: feature gate url dependency (#1843)
* multiaddr: feature gate url dependency Make it possible to exclude url and its dependencies from the dependency tree, by feature gating the from_url* functions in the public API. * Document feature gating of multiaddr::from_url*
This commit is contained in:
parent
41d3f72f0e
commit
fe6e622f3b
@ -8,6 +8,9 @@ keywords = ["multiaddr", "ipfs"]
|
|||||||
license = "MIT"
|
license = "MIT"
|
||||||
version = "0.9.5"
|
version = "0.9.5"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["url"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
arrayref = "0.3"
|
arrayref = "0.3"
|
||||||
bs58 = "0.4.0"
|
bs58 = "0.4.0"
|
||||||
@ -18,7 +21,7 @@ percent-encoding = "2.1.0"
|
|||||||
serde = "1.0.70"
|
serde = "1.0.70"
|
||||||
static_assertions = "1.1"
|
static_assertions = "1.1"
|
||||||
unsigned-varint = "0.5"
|
unsigned-varint = "0.5"
|
||||||
url = { version = "2.1.0", default-features = false }
|
url = { version = "2.1.0", optional = true, default-features = false }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
bincode = "1"
|
bincode = "1"
|
||||||
|
@ -7,6 +7,9 @@ use std::{error, fmt, iter, net::IpAddr};
|
|||||||
/// generated multiaddress. This includes a username, password, path (if not supported by the
|
/// generated multiaddress. This includes a username, password, path (if not supported by the
|
||||||
/// multiaddr), and query string.
|
/// 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:
|
/// The supported URL schemes are:
|
||||||
///
|
///
|
||||||
/// - `ws://example.com/`
|
/// - `ws://example.com/`
|
||||||
@ -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
|
/// 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.
|
/// 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
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -5,6 +5,8 @@ pub use multihash;
|
|||||||
mod protocol;
|
mod protocol;
|
||||||
mod onion_addr;
|
mod onion_addr;
|
||||||
mod errors;
|
mod errors;
|
||||||
|
|
||||||
|
#[cfg(feature = "url")]
|
||||||
mod from_url;
|
mod from_url;
|
||||||
|
|
||||||
use serde::{
|
use serde::{
|
||||||
@ -25,10 +27,12 @@ use std::{
|
|||||||
sync::Arc
|
sync::Arc
|
||||||
};
|
};
|
||||||
pub use self::errors::{Result, Error};
|
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::protocol::Protocol;
|
||||||
pub use self::onion_addr::Onion3Addr;
|
pub use self::onion_addr::Onion3Addr;
|
||||||
|
|
||||||
|
#[cfg(feature = "url")]
|
||||||
|
pub use self::from_url::{FromUrlErr, from_url, from_url_lossy};
|
||||||
|
|
||||||
static_assertions::const_assert! {
|
static_assertions::const_assert! {
|
||||||
// This check is most certainly overkill right now, but done here
|
// This check is most certainly overkill right now, but done here
|
||||||
// anyway to ensure the `as u64` casts in this crate are safe.
|
// anyway to ensure the `as u64` casts in this crate are safe.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user