Source
pub fn writeToStream(
uri: Uri,
options: WriteToStreamOptions,
writer: anytype,
) @TypeOf(writer).Error!void {
if (options.scheme) {
try writer.print("{s}:", .{uri.scheme});
if (options.authority and uri.host != null) {
try writer.writeAll("//");
}
}
if (options.authority) {
if (options.authentication and uri.host != null) {
if (uri.user) |user| {
try writer.print("{user}", .{user});
if (uri.password) |password| {
try writer.print(":{password}", .{password});
}
try writer.writeByte('@');
}
}
if (uri.host) |host| {
try writer.print("{host}", .{host});
if (options.port) {
if (uri.port) |port| try writer.print(":{d}", .{port});
}
}
}
if (options.path) {
try writer.print("{path}", .{
if (uri.path.isEmpty()) Uri.Component{ .percent_encoded = "/" } else uri.path,
});
if (options.query) {
if (uri.query) |query| try writer.print("?{query}", .{query});
}
if (options.fragment) {
if (uri.fragment) |fragment| try writer.print("#{fragment}", .{fragment});
}
}
}