MyBoost.deserialize constructor

MyBoost.deserialize(
  1. BinaryReader reader
)

Deserialize.

Implementation

factory MyBoost.deserialize(BinaryReader reader) {
  // Read [MyBoost] fields.
  final flags = reader.readInt32();
  final slot = reader.readInt32();
  final hasPeerField = (flags & 1) != 0;
  final peer = hasPeerField ? reader.readObject() as PeerBase : null;
  final date = reader.readDateTime();
  final expires = reader.readDateTime();
  final hasCooldownUntilDateField = (flags & 2) != 0;
  final cooldownUntilDate =
      hasCooldownUntilDateField ? reader.readDateTime() : null;

  // Construct [MyBoost] object.
  final returnValue = MyBoost(
    slot: slot,
    peer: peer,
    date: date,
    expires: expires,
    cooldownUntilDate: cooldownUntilDate,
  );

  // Now return the deserialized [MyBoost].
  return returnValue;
}