Skip to main content

parse_report_usage_result

Function parse_report_usage_result 

Source
pub fn parse_report_usage_result(
    raw: &Value,
) -> Result<ReportUsageResult, SdkError>
Expand description

Parse the wire-format result of the ff_report_usage_and_check Lua function into a typed ReportUsageResult.

Standard format: {1, "OK"}, {1, "SOFT_BREACH", dim, current, limit}, {1, "HARD_BREACH", dim, current, limit}, {1, "ALREADY_APPLIED"}. Status code != 1 is parsed as a ScriptError via ScriptError::from_code_with_detail.

Exposed as pub so downstream SDKs that speak the same wire format — notably cairn-fabric’s budget_service::parse_spend_result — can call this directly instead of re-implementing the parse. Keeping one parser paired with the producer (the Lua function registered at lua/budget.lua:99, ff_report_usage_and_check) is the defence against silent format drift between producer and consumer.