MCPcopy Index your code
hub / github.com/RustPython/RustPython / gen_error_codes_rust

Function gen_error_codes_rust

scripts/make_ssl_data_rs.py:89–103  ·  view source on GitHub ↗

Generate Rust phf map for error codes

(args)

Source from the content-addressed store, hash-verified

87
88
89def gen_error_codes_rust(args):
90 """Generate Rust phf map for error codes"""
91 yield "// Maps encoded (lib, reason) -> error mnemonic"
92 yield '// Example: encode_error_key(20, 134) -> "CERTIFICATE_VERIFY_FAILED"'
93 yield "// Key encoding: (lib << 32) | reason"
94 yield "pub static ERROR_CODES: phf::Map<u64, &'static str> = phf_map! {"
95 for reason, libname, errname, num in args.reasons:
96 if libname not in args.lib2errnum:
97 continue
98 lib_num = args.lib2errnum[libname]
99 # Encode (lib, reason) as single u64
100 key = (lib_num << 32) | num
101 yield f' {key}u64 => "{errname}",'
102 yield "};"
103 yield ""
104
105
106def main():

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected