Skip to main content

parse_initial_value

Function parse_initial_value 

Source
pub fn parse_initial_value(char_uuid: &str, value: &Value) -> Result<Vec<u8>>
Expand description

Decode a characteristic’s initial_value from add_service.

Absent is Vec::new() — a characteristic may legitimately start empty. Present but not hex is an error, not zero bytes: unwrap_or_default() here used to turn a malformed initial_value into zero bytes stored for that characteristic, and the read path then served exactly those zero bytes under RequestResponse::Success on decision=model_silent — telling the central “this characteristic holds nothing” on the strength of a value nobody could read. That is the defect ReadDecision::Unusable exists to prevent one layer up: an answer that cannot be decoded is not an answer.

Extracted so the property is testable. add_service is declared only on bluetooth_ble_started, which the radio-free test loop never raises, so there is no way to reach this through run_event_loop_without_radio — and reaching it by returning add_service from a read response is a mock no real model could produce.