Due to all the changes to create generic types a lot of the types specified in various bits of documentation were actually wrong. They've been fixed.
Also delete a redundant duplicate function writeUID
Note - I'll update documentation in a follow-up PR
Remove SequenceRange and SequenceRangeSet and replace with new MessageIdentifier* types.
Motivation:
There was lots of very complicated duplicate code, and there was about to be more if we didn't make the new MessageIdentifier types.
Modifications:
Replace basically every occurrence of SequenceRange with MessageIdentifierRange<SequenceNumber> and SequenceRangeSet with MessageIdentifierSet<SequenceRangeNumber>.
Result:
Lots of lines deleted.
In a previous PR we made UID conform to a new protocol MessageIdentifier. This PR continues the trend of removing concrete types and replacing them with generic types.
In this case we have UIDSet and UIDSetNonEmpty. These are identical to SequenceNumberSet and SequenceNumberSetNonEmpty. To allow us to remove the duplicate code a new generic type MessageIdentifierSet has been defined that takes a generic parameter T: MessageIdentifier. Both UID and SequenceNumber conform to MessageIdentifier.
In the next PR I will remove the code for SequenceNumberSet* and replace with MessageIdentifierSet. This PR only addresses the UIDSet* types.
Note: I will update all documentation in another (probably the last) PR.
A "message identifier" can be a UID, a SequenceNumber, or an unknown instance of the two (because they look the same it's impossible to distinguish when parsing).
Originally we had the 3 types duplicated 3 times, however this PR brings us closer to have one implementation. While code duplication isn't usually "that bad", in this case it can be an issue as :
The code is complicated
There's a lot of it
This PR works to address a few things, using the UID type as a proof-of-concept:
Make UID conform to a protocol MessageIdentifier
Create a new MessageIdentifierRange type that will eventually replace the UIDRange and SequenceNumberRange types.
Resolves#556
We've talked quite a bit offline, and decided that for now @_spi is the way to go, as it avoids build system issues. The goal is to remove the number of underscored public types and fields.
motivation: use standard format across all of our projects
changes:
* add .swiftformat settings based on what we use in other projects
* validate format in the sanity script
* format