Skip to main content

decode_consumer_info

Function decode_consumer_info 

Source
pub fn decode_consumer_info(data: &[u8]) -> Result<ConsumerInfo, IdentityError>
Expand description

Decode a SCALE-encoded ConsumerInfo from a state_getStorage response.

SCALE layout (in field order):

  1. identifier_key: 65 bytes (fixed array, no length prefix)
  2. full_username: Option<BoundedVec<u8, 32>>0x00 = None, 0x01 + compact_len + bytes = Some
  3. lite_username: BoundedVec<u8, 32> — compact_len + bytes
  4. credibility: enum — 0x00 = Lite, 0x01 + alias(32B) + last_update(u64 LE) = Person

Fields after credibility (e.g. stmt_store_slots) are intentionally skipped — clients do not use them.

Returns Err for empty input, truncated data, invalid UTF-8, or unknown enum tags.