converting `Dname` to lowercase
nicki-krizek opened this issue · comments
I have an instance of possibly mixed-case Dname and I would like to get the lowercase version of it. Ideally, I would call some method like Dname::into_lowercase()
to obtain it.
I have not found an easy way to do that with the existing API, but I might be missing something. So far, I just do the conversion like this:
let dname = Dname::bytes_from_str("eXaMPLe.Com").unwrap();
let dname_lowercase: Dname<Vec<u8>> = Dname::from_octets(
dname
.as_octets()
.iter()
.map(u8::to_ascii_lowercase)
.collect(),
).unwrap();
It works, but it's a little cumbersome. Obtaining a lowercase version of a Dname seems like a common enough use-case to warrant some library function.
That seems like an oversight indeed. We will add two methods make_canonical
which converts in place and to_canonical
which returns a new value to all the name types as appropriate.