decode method

RitoFootnote decode(
  1. Uint8List bytes
)

Implementation

RitoFootnote decode(Uint8List bytes) {
  if (bytes.length > ritoMaxWireBytes) {
    throw const FormatException('RITOFTN1 exceeds the byte limit.');
  }
  final reader = RitoBinaryReader(bytes);
  reader.expectMagic(_magic, 'footnote magic');
  final version = reader.uint32('footnote wire version');
  if (version != 1) {
    reader.fail('unsupported footnote wire version: $version');
  }
  final declaredLength = reader.uint64('footnote total length');
  if (declaredLength != bytes.length) {
    reader.fail('footnote total length does not match input');
  }
  final footnote = RitoFootnote(
    artifactId: reader.externalId('footnote artifact id'),
    key: reader.string('footnote key'),
    kind: _kind(reader),
    text: reader.string('footnote text'),
    html: reader.string('footnote html'),
  );
  reader.finish('footnote wire message');
  return footnote;
}