unmarshal library

Descriptor-driven protobuf binary unmarshaling (decoding).

Decodes raw protobuf binary bytes into a message represented as Map<String, Object?>, using a list of field descriptors that map field numbers to names and types.

Field descriptor format (same as marshal):

{
  'number': int,        // protobuf field number
  'name': String,       // field name in the output map
  'type': String,       // protobuf type: int32, uint32, sint32, int64,
                        //   uint64, sint64, bool, enum, fixed32, sfixed32,
                        //   fixed64, sfixed64, float, double, string,
                        //   bytes, message
  'repeated': bool?,    // true if the field is repeated (optional)
  'mapEntry': bool?,    // true if this is a map field (optional)
  'keyType': String?,   // map key type (required if mapEntry is true)
  'valueType': String?, // map value type (required if mapEntry is true)
  'messageDescriptor':  // sub-message descriptor (for type == 'message')
      List<Map<String, Object?>>?,
}

References:

Constants

unknownFieldsKey → const String
Reserved message-map key under which a decoded message stores the raw bytes (tag + value, in wire order) of fields not in its descriptor, so marshal can re-emit them. The $ prefix cannot collide with a real proto field name. Skipped by the descriptor-driven marshalers, appended verbatim by marshal.

Functions

findFieldByNumber(List<Map<String, Object?>> descriptor, int fieldNumber) Map<String, Object?>?
Find a field descriptor by field number.
skipField(List<int> bytes, int offset, int wireType) int
Skip an unknown field (field number not in descriptor).
unmarshal(List<int> bytes, List<Map<String, Object?>> descriptor) Map<String, Object?>
unmarshalFieldValue(List<int> bytes, int offset, int wireType, String fieldType) Map<String, Object?>
Decode a single field value given its wire type and field type.
unmarshalMapField(List<int> entryBytes, String keyType, String valueType) Map<String, Object?>
Decode a map field entry from its raw bytes.
unmarshalRepeated(List<int> bytes, int offset, int wireType, String fieldType) Map<String, Object?>
Decode a repeated field. Handles both packed (wire type 2) and unpacked (each element has its own tag) encoding.