Motivation:
In general we should try to be specific about what we're referring to.
"Structured headers" is not really an accurate description of what this
module works with: "Structured Header Field Values", or "Structured
Field Value" is usually better. To that end this change adjusts our
naming to be closer to what we want. It also changes our module names to
prioritise the use of the Codable-based one.
Modifications:
- Renamed CodableStructuredHeaders to StructuredFieldValues.
- Renamed StructuredHeaders to RawStructuredFieldValues.
- Renamed a number of types from Field to FieldValue.
- Renamed a number of types from Header to Field or FieldValue.
- Renamed some functions along the above lines.
Result:
Better and more consistent terminology will be used.
* fix formatting so that sanity script passes
motivation: consistent formatting as prep for OSS
changes: run swiftformat to align formatting
* dont use TSAN on 18.04
Motivation:
Early on in the design of Structured Headers I made a conscious effort
to try to avoid transforming types in the low-level API. This design was
built on the assumption that strings, tokens, and some other data types
could be built entirely as slices of the backing data.
Unfortunately, this isn't true: because of the need to escape chars in
Strings, it became necessary to start using more complex types in Item.
Eventually, we ended up in a place where the only field in Item that
actually stored backing data was `.undecodedByteSequence`.
This field forced almost the entire set of types in the
StructuredHeaders module to be generic, just for the sake of carrying
this one slice type around. This prevented powerful optimisations,
bloated code size, and forced additional unnecessary heap allocations.
It also forced us to constrain the types used in the parser to those
where the subsequence type was Hashable, which excluded some really
important types (like `String.UTF8View`).
Fundamentally, this genericism was hurting more than it helped at this
point, so I bit the bullet and replaced the slice type with `String` for
`undecodedByteSequence`. This led to a huge cascading removal of generic
type parameters for a wide range of types, as well as the removal of the
"must have hashable subsequence" constraints on the parser data type.
This lifts an enormous amount of complexity out of the module at the
extremely minor cost of forcing an allocation whenever we have a lot of
undecoded binary data: not a huge cost, in my view, and well worth what
we got back in return.
Modifications:
- Remove generic type parameter in BaseItem.
- Remove generic types everywhere else.
- Remove hashable constraint.
Result:
Better, faster, simpler code.
Motivation:
Right now we disambiguate the multiple top-level SH types by using three
separate entry points on the encoder/decoder. This isn't great: it
forces that information to be known statically at compile time, making
it much harder to write generic APIs that use structured header fields.
Modifications:
- Provide a new protocol, `StructuredHeaderField`, that must be used for
the top-level `Codable` object.
- Provide `StructuredHeaderFieldType` to communicate the types of
structured header fields.
- Remove the multiple entry points.
- Update the tests.
Result:
Types will encode what kind of structured header field they are.
Motivation:
We had a proliferation of decode/encode methods that required users to
tell us how to encode their structured header field. This is a bit
annoying for two reasons: firstly, it requires users to encode this
piece of information separately from their header field; secondly, it
makes it very hard to offer a generic interface to load something as a
structured header field!
Modifications:
- Add a new StructuredHeaderField protocol that refines Codable and
expresses what type of header field is used.
- Remove the fancy encode/decode methods.
Result:
Simpler interfaces.
Motivation:
A number of the changes in the code for running on Linux
were not validated ahead of time, and broke the build.
Modifications:
- Correct the spelling of Glibc
- Modified string initialization on non-Darwin platforms
Results:
Builds and passes tests on Linux