Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › std/ › Uri.zig › writeToStream
writeToStream
Uri.writeToStream
pub fn writeToStream (uri : *const Uri , writer : *Writer , flags : Format .Flags ) Writer .Error !void
File
Code
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 );
}
}
}
}