You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a situation in which I'm reading data from a stream. However, the stream is already split into chunks of a known size, where each chunk is parsed independently. Each chunk is represented by a ByteArray that I know will never mutate.
The entities I'm parsing are recursive, so I represent each entity as the entire ByteArray and an IntRange to know where it starts and ends. Writing a RawSource implementation based on this was very simple.
However, Kotlinx-io only offers utilities for Source, in particular the methods to parse integers in big-endian and little-endian notations. I also need .peek() to be able to know some things. At the moment this means I have to use myCustomRawSource.buffered() to get an instance of Source, but this creates the entire Buffer machinery which is frankly unnecessary here, since all data is already within a ByteArray. .peek() could be trivially implemented using a single integer to remember the current index, etc.
However, since Source is sealed, I cannot create a custom implementation that would take advantage of the source data already being buffered.
I don't understand why the library forbids other Source implementations and makes Source.buffer part of the (semi)-public API.
The text was updated successfully, but these errors were encountered:
I have a situation in which I'm reading data from a stream. However, the stream is already split into chunks of a known size, where each chunk is parsed independently. Each chunk is represented by a
ByteArray
that I know will never mutate.The entities I'm parsing are recursive, so I represent each entity as the entire
ByteArray
and anIntRange
to know where it starts and ends. Writing aRawSource
implementation based on this was very simple.However, Kotlinx-io only offers utilities for
Source
, in particular the methods to parse integers in big-endian and little-endian notations. I also need.peek()
to be able to know some things. At the moment this means I have to usemyCustomRawSource.buffered()
to get an instance ofSource
, but this creates the entireBuffer
machinery which is frankly unnecessary here, since all data is already within aByteArray
..peek()
could be trivially implemented using a single integer to remember the current index, etc.However, since
Source
issealed
, I cannot create a custom implementation that would take advantage of the source data already being buffered.I don't understand why the library forbids other
Source
implementations and makesSource.buffer
part of the (semi)-public API.The text was updated successfully, but these errors were encountered: