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/ › crypto/ › Certificate.zig › parseVersion
parseVersion
Certificate.parseVersion
pub fn parseVersion (bytes : []const u8 , version_elem : der .Element ) ParseVersionError !Version
File
Code
pub fn parseVersion (bytes : []const u8 , version_elem : der .Element ) ParseVersionError !Version {
if (@as (u8 , @bitCast (version_elem .identifier )) != 0xa0 )
return .v1 ;
if (version_elem .slice .end - version_elem .slice .start != 3 )
return error .CertificateFieldHasInvalidLength ;
const encoded_version = bytes [version_elem .slice .start ..version_elem .slice .end ];
if (mem .eql (u8 , encoded_version , "\x02\x01\x02" )) {
return .v3 ;
} else if (mem .eql (u8 , encoded_version , "\x02\x01\x01" )) {
return .v2 ;
} else if (mem .eql (u8 , encoded_version , "\x02\x01\x00" )) {
return .v1 ;
}
return error .UnsupportedCertificateVersion ;
}