Function sc_network::multiaddr::from_url

source ·
pub fn from_url(url: &str) -> Result<Multiaddr, FromUrlErr>
Expand description

Attempts to parse an URL into a multiaddress.

This function will return an error if some information in the URL cannot be retained in the 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/
  • wss://example.com/
  • http://example.com/
  • https://example.com/
  • unix:/foo/bar

Example

let addr = multiaddr::from_url("ws://127.0.0.1:8080/").unwrap();
assert_eq!(addr, "/ip4/127.0.0.1/tcp/8080/ws".parse().unwrap());