mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-09 02:56:10 +00:00
LibURL: Promote Host to a proper class
This lets us move a few Host-related functions (like serialization and checks for what the Host is) into Host instead of having them dotted around the codebase. For now, the interface is still very Variant-like, to avoid having to change quite so much in one go.
This commit is contained in:
parent
90e763de4c
commit
63688148b9
Notes:
github-actions[bot]
2024-11-30 11:24:04 +00:00
Author: https://github.com/AtkinsSJ
Commit: 63688148b9
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2610
Reviewed-by: https://github.com/shannonbooth ✅
14 changed files with 212 additions and 134 deletions
|
@ -111,6 +111,13 @@ ErrorOr<URL::Origin> decode(Decoder& decoder)
|
|||
return URL::Origin { move(scheme), move(host), port };
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<URL::Host> decode(Decoder& decoder)
|
||||
{
|
||||
auto value = TRY(decoder.decode<URL::Host::VariantType>());
|
||||
return URL::Host { move(value) };
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<File> decode(Decoder& decoder)
|
||||
{
|
||||
|
|
|
@ -108,6 +108,9 @@ ErrorOr<URL::URL> decode(Decoder&);
|
|||
template<>
|
||||
ErrorOr<URL::Origin> decode(Decoder&);
|
||||
|
||||
template<>
|
||||
ErrorOr<URL::Host> decode(Decoder&);
|
||||
|
||||
template<>
|
||||
ErrorOr<File> decode(Decoder&);
|
||||
|
||||
|
|
|
@ -131,6 +131,13 @@ ErrorOr<void> encode(Encoder& encoder, URL::Origin const& origin)
|
|||
return {};
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<void> encode(Encoder& encoder, URL::Host const& host)
|
||||
{
|
||||
TRY(encoder.encode(host.value()));
|
||||
return {};
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<void> encode(Encoder& encoder, File const& file)
|
||||
{
|
||||
|
|
|
@ -107,6 +107,9 @@ ErrorOr<void> encode(Encoder&, URL::URL const&);
|
|||
template<>
|
||||
ErrorOr<void> encode(Encoder&, URL::Origin const&);
|
||||
|
||||
template<>
|
||||
ErrorOr<void> encode(Encoder&, URL::Host const&);
|
||||
|
||||
template<>
|
||||
ErrorOr<void> encode(Encoder&, File const&);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue