   ///   - objectType: The type as which this field should be read
   ///   - index: The index of this field
   /// - Returns: The decoded field
-  func readField<FieldType: ByteTreeObjectDecodable>(
+  mutating func readField<FieldType: ByteTreeObjectDecodable>(
     _ objectType: FieldType.Type, index: Int
   ) -> FieldType {
     advanceAndValidateIndex(index)

/// Helper object for reading objects out a ByteTree. Keeps track that fields
/// are not read out of order and discards all trailing fields that were present
/// in the binary format but were not handled when reading the object.
class ByteTreeObjectReader {
  /// The reader that holds a reference to the data from which the object is
  /// read
  private let reader: ByteTreeReader

  /// advances the reader by one field so that the next field can be read.
  ///
  /// - Parameter index: The index of the field that shall be discarded
  mutating func discardField(index: Int) {
    advanceAndValidateIndex(index)
    reader.discardField()
  }

  fileprivate mutating func finalize() {
    // Discard all fields that have not been read
    while nextIndex < numFields {
      discardField(index: nextIndex)
