Skip to main content

apply_app_data_update_payload

Function apply_app_data_update_payload 

Source
pub fn apply_app_data_update_payload(
    id: ComponentId,
    payload: &[u8],
    old_value: Option<&[u8]>,
    registry: &ComponentRegistry,
) -> Result<Vec<u8>, ComponentSourceError>
Expand description

Decode an incoming AppDataUpdateOperation::Update(bytes) payload and produce the new full bytes of the component, given the prior stored bytes (if any). Update-only — Remove carries no payload and is handled directly by the caller.

Immutable components are rejected with ComponentSourceError::ImmutableUpdate only when a prior value already exists — the bootstrap commit is the canonical first-insert path for immutable seeds, so this layer must allow an Update whose old_value is None. The bootstrap validator catches malicious initial values upstream via byte-compare.

A bounded component’s payload is held to the element bound before anything else, so the result does not depend on the state it applies to; the new value is then held to the snapshot bound.