decode method

RitoArtifact decode(
  1. Uint8List bytes
)

Implementation

RitoArtifact decode(Uint8List bytes) {
  if (bytes.length > ritoMaxWireBytes) {
    throw const FormatException('RITOART1 exceeds the byte limit.');
  }
  final reader = RitoBinaryReader(bytes);
  reader.expectMagic(_magic, 'artifact magic');
  final version = reader.uint32('artifact wire version');
  if (version != wireVersion) {
    reader.fail('unsupported artifact wire version: $version');
  }
  final declaredLength = reader.uint64('artifact total length');
  if (declaredLength != bytes.length) {
    reader.fail('artifact total length does not match input');
  }
  final artifact = _artifact(reader);
  reader.finish('artifact wire message');
  return artifact;
}