code wiki / (root) / nx_result.nx

nx_result.nx

buildroot/runtime/nx_result.nx

4323 B112 linesdepth 3pulls 3 transitivereach 226 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_result.nx -- proper Result type for substrate-side error handling. Per user 2026-05-14: "if we dont have capabilities and adding them doesnt add bullshit like nulls where nulls shouldnt be go deep and build up". This replaces the `return -1` / `return null` sentinel pattern with a Result struct the caller MUST inspect before reading the value. Discipline: result := nx_result_ok(value) or nx_result_err(code) caller calls nx_result_is_ok(result) only if 1 does caller call nx_result_unwrap(result) on 0 caller calls nx_result_err_code(result) to dispatch No null-pointer returns. No -1 sentinels. Every error has a named code from the NX_ERR_* sealed enum.

dependencies 3 imports · 89 importers

nx_syscalls.nx nx_runtime.nx nx_tier.nx nx_result.nx nx_answer.nx nx_answer_test.nx nx_atp_to_derive.nx nx_atp_to_derive_test.nx nx_avatar_encode.nx nx_avatar_encode_test.nx nx_avatar_solve_test.nx nx_avatar_split.nx nx_avatar_split_test.nx nx_backward_subsume_test.nx

diagram shows first 10 each side; +0 more imports, +79 more importers in the complete lists below.

imports: nx_syscalls.nxnx_runtime.nxnx_tier.nx

imported by: nx_answer.nxnx_answer_test.nxnx_atp_to_derive.nxnx_atp_to_derive_test.nxnx_avatar_encode.nxnx_avatar_encode_test.nxnx_avatar_solve_test.nxnx_avatar_split.nxnx_avatar_split_test.nxnx_backward_subsume_test.nxnx_casc_bench.nxnx_casc_runner_test.nxnx_clause_components.nxnx_clause_components_test.nxnx_clause_weight_test.nxnx_congruence_closure.nxnx_demodulation.nxnx_demodulation_test.nxnx_discount_test.nxnx_disctree.nxnx_disctree_test.nxnx_eq_factor.nxnx_eq_factor_test.nxnx_file_result.nxnx_file_result_test.nxnx_fmb.nxnx_fmb_test.nxnx_fof.nxnx_fof_cnf.nxnx_fof_cnf_test.nxnx_fof_parse.nxnx_fof_parse_test.nxnx_fof_tseitin.nxnx_fof_tseitin_test.nxnx_hyperres.nxnx_hyperres_test.nxnx_indexed_subsume_test.nxnx_inst_gen.nxnx_inst_gen_test.nxnx_kernel_v2.nxnx_lpo.nxnx_lpo_test.nxnx_math_games.nxnx_math_games_test.nxnx_paramodulation.nxnx_paramodulation_test.nxnx_pre_sat.nxnx_pre_sat_test.nxnx_proof_log.nxnx_proof_log_test.nxnx_pure_lit.nxnx_pure_lit_test.nxnx_resolution.nxnx_resolution_test.nxnx_result_test.nxnx_saturation.nxnx_saturation_test.nxnx_selection.nxnx_selection_test.nxnx_sine.nxnx_sine_test.nxnx_smtlib_parse.nxnx_smtlib_parse_test.nxnx_solve.nxnx_solve_test.nxnx_subsumption.nxnx_subsumption_test.nxnx_tautology.nxnx_tautology_test.nxnx_term_order.nxnx_term_order_test.nxnx_tptp.nxnx_tptp_emit.nxnx_tptp_emit_test.nxnx_tptp_formula.nxnx_tptp_formula_test.nxnx_tptp_load.nxnx_tptp_load_any.nxnx_tptp_load_test.nxnx_tptp_symtab.nxnx_tptp_term.nxnx_tptp_test.nxnx_tptp_write_test.nxnx_tstp_emit.nxnx_tstp_emit_test.nxnx_unified_solver.nxnx_unified_solver_test.nxnx_unify.nxnx_unify_test.nx

structs

62struct NxResult

consts

29const NX_ERR_NONE: nx_int = 0
30const NX_ERR_OUT_OF_RANGE: nx_int = 1
31const NX_ERR_INVALID_INPUT: nx_int = 2
32const NX_ERR_FILE_NOT_FOUND: nx_int = 3
33const NX_ERR_PARSE_FAILED: nx_int = 4
34const NX_ERR_TAG_MISMATCH: nx_int = 5
35const NX_ERR_NOT_FOUND: nx_int = 6
36const NX_ERR_ALLOC_FAILED: nx_int = 7
37const NX_ERR_INVALID_STATE: nx_int = 8
38const NX_ERR_DIVIDE_BY_ZERO: nx_int = 9
39const NX_ERR_OVERFLOW: nx_int = 10
40const NX_ERR_UNKNOWN_CODE: nx_int = 11
68const NX_RESULT_BYTES: nx_int = 24

functions

42func nx_err_name(code: nx_int) -> *u8
70func nx_result_ok(value: nx_int) -> *NxResult
78func nx_result_err(code: nx_int) -> *NxResult
87func nx_result_is_ok(r: *NxResult) -> nx_int { return r.status }
88func nx_result_is_err(r: *NxResult) -> nx_int
97func nx_result_unwrap(r: *NxResult) -> nx_int
102func nx_result_err_code(r: *NxResult) -> nx_int { return r.err_code }
106func nx_result_must_unwrap(r: *NxResult, ctx: *u8) -> nx_int