decodeScale static method
Implementation
static LayoutDecodeResult<BigInt> decodeScale(
List<int> bytes, {
int offset = 0,
}) {
final byte = bytes[offset];
switch (byte & 0x03) {
case 0x00:
return LayoutDecodeResult(consumed: 1, value: BigInt.from(byte) >> 2);
case 0x01:
final val = fromBytes(
bytes: bytes,
offset: offset,
end: offset + 2,
sign: false,
byteOrder: Endian.little,
);
return LayoutDecodeResult(consumed: 2, value: val >> 2);
case 0x02:
final val = fromBytes(
bytes: bytes,
offset: offset,
end: offset + 4,
byteOrder: Endian.little,
);
return LayoutDecodeResult(consumed: 4, value: val >> 2);
default:
final int o = (byte >> 2) + 5;
final val = fromBytes(
bytes: bytes,
offset: offset + 1,
end: offset + o,
byteOrder: Endian.little,
);
return LayoutDecodeResult(consumed: o, value: val);
}
}