swift-nio icon indicating copy to clipboard operation
swift-nio copied to clipboard

Extract `ByteBuffer` into it's own module

Open 0xTim opened this issue 11 months ago • 3 comments

As more packages adopt Swift concurrency across the ecosystem, we're hitting cases more and more where we're pulling in NIOCore solely to be able to use ByteBuffer. It would be great if we could extract ByteBuffer into its own module (or even better own package) to provide a modern, consistent bag of bytes implementation for the ecosystem.

0xTim avatar Apr 01 '25 14:04 0xTim

I’m fairly strongly opposed to this. It’s not a good pattern for the ecosystem to have NIO define currency types for use-cases outside of networking. Our intention is not to have NIO be an “un-standard library”.

It would be better, I think, for the SSWG to raise this need with the relevant steering group and come up with a position.

Lukasa avatar Apr 01 '25 20:04 Lukasa

Yeah we (the SSWG and steering groups) do need to come up with a position as to what should be done. The difficulty will be rolling it out in the ecosystem without necessitating copies between different types etc (we already hit issues when trying to use AsyncSequence<ArraySlice<UInt8>>

0xTim avatar Apr 07 '25 13:04 0xTim

I 100% agree that that is the shape of the problem to be solved. I also want to make sure that the ecosystem as a whole, not just NIO, gets to participate in making that happen, which is why I'm reluctant for ByteBuffer to be the currency type. This problem is broader than Swift on Server: it affects interaction with the Apple platform SDKs (which pervasively use Data) and the standard-library-only ecosystem (e.g. embedded). Coming up with a good answer here requires a high level view of the problem space.

Lukasa avatar Apr 07 '25 13:04 Lukasa