Describe the bug
Some APIs like .string(...), .bytes(...) and size parameters take integers of units unknown to the programmer.
For example:
output: .string(limit: 12345, encoding: UTF16.self)
What's the limit here? 12345 bytes, 12345 UTF16 code units, 12345 String.Characters? This is unnecessarily unclear. I would argue that the limit should be explicit. Compare this for example to NIOFileSystem's API:
let plan = try await ByteBuffer(
contentsOf: "/Users/hal9000/demise-of-dave.txt",
maximumSizeAllowed: .mebibytes(1)
)
which is much clearer than maximumSizeAllowed: 1024 * 1024 or similar.
Describe the bug
Some APIs like
.string(...),.bytes(...)andsizeparameters take integers of units unknown to the programmer.For example:
What's the limit here? 12345 bytes, 12345 UTF16 code units, 12345
String.Characters? This is unnecessarily unclear. I would argue that the limit should be explicit. Compare this for example to NIOFileSystem's API:which is much clearer than
maximumSizeAllowed: 1024 * 1024or similar.