   fileprivate func read<T: ByteTreeObjectDecodable>(
     _ objectType: T.Type
   ) -> T {
-    let numFields = readFieldLength()
+    let numFields = readObjectLength()
     let objectReader = ByteTreeObjectReader(reader: self,
                                             numFields: numFields)
     return T.read(from: objectReader, numFields: numFields, userInfo: userInfo)

    return result
  }

  /// Read the number of fields in an object or the binary length of a scalar
  /// field.
  ///
  /// - Returns: The read value
  private func readFieldLength() -> Int {
    return Int(UInt32(littleEndian: readRaw(UInt32.self)))
  }

  /// Read the protocol version and validate that it can be read using the given


  /// Discard the next scalar field, advancing the pointer to the next field
  fileprivate func discardField() {
    let (isObject, length) = readFieldLength()
    if isObject {
      // Discard object by discarding all its objects
      for _ in 0..<length {
        discardField()
      }
    } else {
      // Discard scalar
      pointer = pointer.advanced(by: length)
    }
  }
}

