makeRecordCodec = (label, labelType, readBody, writeBody) => {
  /**
   * @param {SyrupReader} syrupReader
   * @returns {any}
   */
  const read = syrupReader => {
    syrupReader.enterRecord();
    const labelInfo = syrupReader.readRecordLabel();
    if (labelInfo.type !== labelType) {
      throw Error(
        `RecordCodec: Expected label type ${quote(labelType)} for ${quote(label)}, got ${quote(labelInfo.type)}`,
      );
    }
    const labelString =
      labelInfo.type === 'bytestring'
        ? textDecoder.decode(labelInfo.value)
        : labelInfo.value;
    if (labelString !== label) {
      throw Error(
        `RecordCodec: Expected label ${quote(label)}, got ${quote(labelString)}`,
      );
    }
    const result = readBody(syrupReader);
    syrupReader.exitRecord();
    return result;
  };
  /**
   * @param {any} value
   * @param {SyrupWriter} syrupWriter
   */
  const write = (value, syrupWriter) => {
    syrupWriter.enterRecord();
    if (labelType === 'selector') {
      syrupWriter.writeSelectorFromString(label);
    } else if (labelType === 'string') {
      syrupWriter.writeString(label);
    } else if (labelType === 'bytestring') {
      syrupWriter.writeBytestring(textEncoder.encode(label));
    }
    writeBody(value, syrupWriter);
    syrupWriter.exitRecord();
  };
  return freeze({
    label,
    read,
    readBody,
    write,
    writeBody,
  });
}
@param {string} label
@param {SyrupRecordLabelType} labelType
@param {function(SyrupReader): any} readBody
@param {function(any, SyrupWriter): void} writeBody
@returns {SyrupRecordCodec}