In order to get the host from the URL, url::Host is needed:
use url::{Url, Host};
use std::net::{SocketAddr, IpAddr};
fn main () {
let url = Url::parse("rtsp://admin:12345@192.168.1.178:10554/tcp/av0_0").unwrap();
let port = url.port().unwrap_or(554);
let ip_address = match url.host() {
Some(Host::Ipv4(ipv4)) => SocketAddr::new(IpAddr::V4(ipv4), port),
//...
wouldn't it be good for rtsp_types to export not only url::Url, but also url::Host because it's so common to need the IP of a host in RTSP (IP cameras mainly use IP instead of domains) that lost of users would have to import URL on their projects just to do that and thus not use the URL from rtsp_types. I can send a PR if you agree.
In order to get the host from the URL,
url::Host
is needed:wouldn't it be good for rtsp_types to export not only
url::Url
, but alsourl::Host
because it's so common to need the IP of a host in RTSP (IP cameras mainly use IP instead of domains) that lost of users would have to import URL on their projects just to do that and thus not use the URL fromrtsp_types
. I can send a PR if you agree.