Skip to content

API issue: Unit (e.g. bytes/characters/code units) omitted when configuring limits/sizes #248

@weissi

Description

@weissi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions