DoxigAlpha

writeToStream

Function parameters

Parameters

#
uri:*const Uri
writer:*Writer
flags:Format.Flags

Type definitions in this namespace

Types

#

Returned value may point into `buffer` or be the original string.

Functions

#
getHost
Returned value may point into `buffer` or be the original string.
getHostAlloc
Returned value may point into `buffer` or be the original string.
percentDecodeBackwards
Percent decodes all %XX where XX is a valid hex number.
percentDecodeInPlace
Percent decodes all %XX where XX is a valid hex number.
parseAfterScheme
Parses the URI or returns an error.
parse
The return value will contain strings pointing into the original `text`.
resolveInPlace
Resolves a URI against a base URI, conforming to

Error sets in this namespace

Error Sets

#

= 255

Values

#

Source

Implementation

#
pub fn writeToStream(uri: *const Uri, writer: *Writer, flags: Format.Flags) Writer.Error!void {
    if (flags.scheme) {
        try writer.print("{s}:", .{uri.scheme});
        if (flags.authority and uri.host != null) {
            try writer.writeAll("//");
        }
    }
    if (flags.authority) {
        if (flags.authentication and uri.host != null) {
            if (uri.user) |user| {
                try user.formatUser(writer);
                if (uri.password) |password| {
                    try writer.writeByte(':');
                    try password.formatPassword(writer);
                }
                try writer.writeByte('@');
            }
        }
        if (uri.host) |host| {
            try host.formatHost(writer);
            if (flags.port) {
                if (uri.port) |port| try writer.print(":{d}", .{port});
            }
        }
    }
    if (flags.path) {
        const uri_path: Component = if (uri.path.isEmpty()) .{ .percent_encoded = "/" } else uri.path;
        try uri_path.formatPath(writer);
        if (flags.query) {
            if (uri.query) |query| {
                try writer.writeByte('?');
                try query.formatQuery(writer);
            }
        }
        if (flags.fragment) {
            if (uri.fragment) |fragment| {
                try writer.writeByte('#');
                try fragment.formatFragment(writer);
            }
        }
    }
}