addr-rs / addr

Parse domain names reliably and quickly in Rust
MIT License
51 stars 12 forks source link

`addr::parse_domain_name()` equivalent in 0.15.2 #15

Closed Edu4rdSHL closed 2 years ago

Edu4rdSHL commented 2 years ago

Hello, thank you for the work on this crate! Prior to 0.15.2 I was using:

use addr::parse_domain_name;

fn parse_domain(target: &str) -> bool {
  parse_domain_name(target).is_ok()
}

However, in 0.15.2 it doesn't seem to be a valid option to do it because addr::parse_domain_name doesn't exist anymore, I have made a quick look at the source code and found out that the equivalent is:

use addr::{parser::DomainName, psl::List};

fn parse_domain(target: &str) -> bool {
  List.parse_domain_name(target).is_ok()
}

Is that correct? Sorry for the basic question but I'm using the crate for critical development and I want to be sure before the change.

Regards, Ed

rushmorem commented 2 years ago

Hello, thank you for the work on this crate!

Hello. It's my pleasure :slightly_smiling_face: I'm glad you like it.

in 0.15.2 it doesn't seem to be a valid option to do it because addr::parse_domain_name doesn't exist anymore.

It still exists. It's part of the psl feature which is enabled by default. You already have it enabled if you are able to import addr::psl::List.

Is that correct?

Yes that's correct. Those two are equivalent.

Sorry for the basic question

It's OK, no apology necessary.

Edu4rdSHL commented 2 years ago

Thank you for the fast reply!

in 0.15.2 it doesn't seem to be a valid option to do it because addr::parse_domain_name doesn't exist anymore.

It still exists. It's part of the psl feature which is enabled by default. You already have it enabled if you are able to import addr::psl::List.

I see, then why I'm not able to import it?

unresolved import `addr::parse_domain_name`
no `parse_domain_name` in the root
rushmorem commented 2 years ago

I can't reproduce this.

$ cat Cargo.toml 
[package]
name = "addr-test"
version = "0.1.0"
edition = "2021"

[dependencies]
addr = "0.15.2"
$ cat src/main.rs 
fn main() {
    addr::parse_domain_name("example.com").unwrap();
}

This runs just fine.

$ cargo tree
addr-test v0.1.0 (/tmp/addr-test)
└── addr v0.15.2
    ├── psl v2.0.64
    │   └── psl-types v2.0.10
    └── psl-types v2.0.10

Try checking cargo tree output to verify the versions of the crate you are running. Which features are you activating in your Cargo.toml?

Edu4rdSHL commented 2 years ago

Found this, apparently, the cargo upgrade command bumped the addr version (I saw that in the logs) but finally it didn't :man_shrugging:

$ cargo tree
snip... v16.0.3 (/home/edu4rdshl/Projects/Rust/snip...)
├── addr v0.14.0
│   ├── psl v2.0.64
│   │   └── psl-types v2.0.10
│   └── psl-types v2.0.10

Thank you so much for the clear steps to investigate the issue :heart:

rushmorem commented 2 years ago

Awesome!