decodeValue method

  1. @override
Map<String, dynamic> decodeValue(
  1. Pipe x,
  2. CType t
)
override

Implementation

@override
Map<String, dynamic> decodeValue(Pipe x, CType t) {
  final variant = checkType(t);
  if ((variant is! VariantClass)) {
    throw 'Not a variant type';
  }
  final idx = (lebDecode(x).toInt());
  if (idx >= variant._fields.length) {
    throw 'Invalid variant index: $idx';
  }
  final entry = variant._fields[idx];
  var wireHash = entry.key, wireType = entry.value;
  for (var fEntry in _fields) {
    var key = fEntry.key, expectType = fEntry.value;
    if (idlLabelToId(wireHash) == idlLabelToId(key)) {
      final value = expectType.decodeValue(x, wireType);
      return {key: value};
    }
  }
  throw 'Cannot find field hash $wireHash';
}