Skip to main content

nix_get_attr_byidx

Function nix_get_attr_byidx 

Source
pub unsafe extern "C" fn nix_get_attr_byidx(
    context: *mut nix_c_context,
    value: *mut nix_value,
    state: *mut EvalState,
    i: c_uint,
    name: *mut *const c_char,
) -> *mut nix_value
Expand description

Get an attribute by index @ingroup value_extract Also gives you the name. Attributes are returned in an unspecified order which is NOT suitable for reproducible operations. In Nix’s domain, reproducibility is paramount. The caller is responsible for sorting the attributes or storing them in an ordered map to ensure deterministic behavior in your application.

Note When Nix does sort attributes, which it does for virtually all intermediate operations and outputs, it uses byte-wise lexicographic order (equivalent to lexicographic order by Unicode scalar value for valid UTF-8). We recommend applying this same ordering for consistency. Call nix_value_decref() when you’re done with the pointer

§Arguments

  • context [out] - Optional, stores error information
  • value [in] - Nix value to inspect
  • state [in] - nix evaluator state
  • i [in] - attribute index
  • name [out] - will store a pointer to the attribute name, valid until state is freed

§Returns

value, NULL in case of errors