sdroege / rtsp-types

RTSP (RFC 7826) types and parsers/serializers
MIT License
25 stars 14 forks source link

Export url::Host too? #9

Closed lattice0 closed 3 years ago

lattice0 commented 3 years ago

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.

sdroege commented 3 years ago

Sounds like a good idea, yes. Please go ahead :)