alef 0.66.0

Opinionated polyglot binding generator for Rust libraries
Documentation
// lastError retrieves the last error from the FFI layer.
func lastError() error {
	code := int32(C.{{ ffi_prefix }}_last_error_code())
	if code == 0 {
		return nil
	}
{% if error_codes %}
	switch code {
{% for error_code in error_codes %}
	case {{ error_code.0 }}:
		return {{ error_code.1 }}
{% endfor %}
	}
{% endif %}
	ctx := C.{{ ffi_prefix }}_last_error_context()
	if ctx == nil {
		return fmt.Errorf("[%d] native error", code)
	}
	message := C.GoString(ctx)
	return fmt.Errorf("[%d] %s", code, message)
}