parse
Converts UTF-8 text to a BuildId.
Function parameters
Parameters
- text:[]const u8
Type definitions in this namespace
Types
- EnvVar
- Collects all the environment variables that Zig could possibly inspect, so
- EmitArtifact
- Every kind of artifact which the compiler can emit.
Functions in this namespace
Functions
- binNameAlloc
- Returns the standard file system basename of a binary generated by the Zig compiler.
- serializeCpu
- Renders a `std.Target.Cpu` value into a textual representation that can be parsed
- fmtId
- Return a Formatter for a Zig identifier, escaping it with `@""` syntax if needed.
- fmtIdFlags
- Return a Formatter for a Zig identifier, escaping it with `@""` syntax if needed.
- fmtString
- Return a formatter for escaping a double quoted Zig string.
- fmtChar
- Return a formatter for escaping a single quoted Zig string.
- stringEscape
- Print the string as escaped contents of a double quoted string.
- charEscape
- Print as escaped contents of a single-quoted string.
- readSourceFileToEndAlloc
- If the source can be UTF-16LE encoded, this function asserts that `gpa`
There are many assumptions in the entire codebase that Zig source files can
Values
- max_src_size
- There are many assumptions in the entire codebase that Zig source files can
Source
Implementation
pub fn parse(text: []const u8) !BuildId {
if (std.mem.eql(u8, text, "none")) {
return .none;
} else if (std.mem.eql(u8, text, "fast")) {
return .fast;
} else if (std.mem.eql(u8, text, "uuid")) {
return .uuid;
} else if (std.mem.eql(u8, text, "sha1") or std.mem.eql(u8, text, "tree")) {
return .sha1;
} else if (std.mem.eql(u8, text, "md5")) {
return .md5;
} else if (std.mem.startsWith(u8, text, "0x")) {
var result: BuildId = .{ .hexstring = undefined };
const slice = try std.fmt.hexToBytes(&result.hexstring.bytes, text[2..]);
result.hexstring.len = @as(u8, @intCast(slice.len));
return result;
}
return error.InvalidBuildIdStyle;
}