I'm working on a wrapper crate for this one to allow more convenient URL manipulation. As part of this I have several types representing hosts and allow for easy extracting/manipulation of domain suffixes and whatnot.
The primary invariant of these types is that Url::set_host doesn't need to do any checks/parsing (aside from "does this URL have a host to set"). It can just use String::replace_range, turn my HostDetails into its HostInternal, and adjust the other metadata based on the change in the host length.
Due to this, actually using Url::set_host with these types adds overhead that currently can only be skipped by enabling the serde feature to get Url::serialize_internal and Url::deserialize_internal, which also opens a lot of issues with optimizations.
My proposal is to simply add equivalents to the existing methods that work on plain tuples:
impl Url {
pub fn into_internal(self) -> (String, u32, u32, u32, u32, HostInternal, Option<u16>, u32, Option<u32>, Option<u32>) {...}
pub fn from_internal(parts: (String, u32, u32, u32, u32, HostInternal, Option<u16>, u32, Option<u32>, Option<u32>)) -> Self {...}
}
This would allow me to do any optimizations I can get away with without bothering you for each individual thing.
I'm working on a wrapper crate for this one to allow more convenient URL manipulation. As part of this I have several types representing hosts and allow for easy extracting/manipulation of domain suffixes and whatnot.
The primary invariant of these types is that
Url::set_hostdoesn't need to do any checks/parsing (aside from "does this URL have a host to set"). It can just useString::replace_range, turn myHostDetailsinto itsHostInternal, and adjust the other metadata based on the change in the host length.Due to this, actually using
Url::set_hostwith these types adds overhead that currently can only be skipped by enabling theserdefeature to getUrl::serialize_internalandUrl::deserialize_internal, which also opens a lot of issues with optimizations.My proposal is to simply add equivalents to the existing methods that work on plain tuples:
This would allow me to do any optimizations I can get away with without bothering you for each individual thing.