Skip to content

An equivalent to Url::serialize_internal and Url::deserialize_internal without serde. #1109

@Scripter17

Description

@Scripter17

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions