Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a bytes type to UDL #1541

Closed
heinrich5991 opened this issue May 15, 2023 · 2 comments · Fixed by #1543
Closed

Add a bytes type to UDL #1541

heinrich5991 opened this issue May 15, 2023 · 2 comments · Fixed by #1543
Labels

Comments

@heinrich5991
Copy link
Contributor

heinrich5991 commented May 15, 2023

Some languages, such as e.g. Python, distinguish between arrays of 8-bit integers (List[int] in Python) and byte buffers (bytes in Python).

This would IMO neatly solve #1299.

Kotlin: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/
Python: https://docs.python.org/3/library/stdtypes.html#bytes

┆Issue is synchronized with this Jira Task
┆Issue Number: UNIFFI-262

@linabutler
Copy link
Member

Hi @heinrich5991, this is a nice suggestion!

A dedicated bytes type would also make working with byte arrays a little more ergonomic in Kotlin (in a component I was writing recently, I had to opt-in to kotlin.ExperimentalUnsignedTypes, then use the toByteArray conversion you linked to turn the List<UByte> into a ByteArray) and Swift (where we could represent them as Data instead of [UInt8]).

@badboy
Copy link
Member

badboy commented May 16, 2023

Over in Glean we also use sequence<u8> in at least one place and having that be bytes would be nice.

heinrich5991 added a commit to heinrich5991/uniffi-rs that referenced this issue May 19, 2023
This type is mapped to the native bytestring type in the various
languages, i.e.

- Kotlin: `UByteArray`
- Python: `bytes`
- Ruby: `String` with `Encoding::BINARY`
- Swift: `Data`

Also add tests exercising this new type.

Fixes mozilla#1299.
Fixes mozilla#1541.
heinrich5991 added a commit to heinrich5991/uniffi-rs that referenced this issue May 22, 2023
This type is mapped to the native bytestring type in the various
languages, i.e.

- Kotlin: `UByteArray`
- Python: `bytes`
- Ruby: `String` with `Encoding::BINARY`
- Swift: `Data`

Also add tests exercising this new type.

Fixes mozilla#1299.
Fixes mozilla#1541.
heinrich5991 added a commit to heinrich5991/uniffi-rs that referenced this issue May 22, 2023
This type is mapped to the native bytestring type in the various
languages, i.e.

- Kotlin: `UByteArray`
- Python: `bytes`
- Ruby: `String` with `Encoding::BINARY`
- Swift: `Data`

Also add tests exercising this new type.

Fixes mozilla#1299.
Fixes mozilla#1541.
heinrich5991 added a commit to heinrich5991/uniffi-rs that referenced this issue May 23, 2023
This type is mapped to the native bytestring type in the various
languages, i.e.

- Kotlin: `UByteArray`
- Python: `bytes`
- Ruby: `String` with `Encoding::BINARY`
- Swift: `Data`

Also add tests exercising this new type.

Fixes mozilla#1299.
Fixes mozilla#1541.
mhammond pushed a commit that referenced this issue May 23, 2023
This type is mapped to the native bytestring type in the various
languages, i.e.

- Kotlin: `ByteArray`
- Python: `bytes`
- Ruby: `String` with `Encoding::BINARY`
- Swift: `Data`

Also add tests exercising this new type.

Fixes #1299.
Fixes #1541.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants