mapbox / mapbox-directions-swift

Traffic-aware directions and map matching in Swift on iOS, macOS, tvOS, watchOS, and Linux
https://www.mapbox.com/navigation/
ISC License
185 stars 90 forks source link

Replace AttributeOptions with more extensible type #718

Open 1ec5 opened 2 years ago

1ec5 commented 2 years ago

AttributeOptions has historically been an OptionSet for convenience and to avoid redundancy: https://github.com/mapbox/mapbox-directions-swift/pull/118#discussion_r109551839. However, after we made it an OptionSet, it became apparent that the Directions API could arbitrarily begin accepting or returning new unrecognized values.

OptionSet is essentially syntactic sugar and a more compact representation of Set composed with an enumeration. We should replace it with an explicit Set and an “extensible enumeration”. This could take the form of either a struct with constants or an enumeration with an unrecognized(_:) case (taking the raw string as an associated value). A less compact representation in memory won’t be a problem, because it’s unlikely that a request would ever specify more than a handful of attributes anyways.

This would be a backwards-incompatible change.

1ec5 commented 2 years ago

As a workaround until the next major version, #748 adds an extensibility hook to AttributeOptions.