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
This works when the caller has a ReadOnlySequence<byte> (usually from a PipeReader) and is parsing messages at that level. Most of our IMessageReader<T> implementations end up creating a SequenceReader<byte> internally over the ReadOnlySequence<byte> to do further parser.
When trying to compose these parsers internally, it usually results is translating from ReadOnlySequence<byte> -> SequenceReader<byte> which is inefficient and inconvenient. Ideally you should be able to keep the SequenceReader<byte> rather than switching back to ReadOnlySequence<byte> and vice versa.
Option 1. Has the disadvantage of not being able to gain efficiency by removing the SequenceReader.
Option 2. Has the disadvantage of requiring you to duplicate code.
I suppose one option would be to add a DIM from the overload accepting a SequenceReader using the one accepting a ReadOnlySequence. When you want to use a SequenceReader internally, you reverse the direction, and implement the one accepting a ReadOnlySequence in terms of the one accepting a SequenceReader. When performance is extremely important, you can implement both seperately.
I don't know how possible it would be to add, if only for the message readers that are ReadOnlySequence<byte> pass-throughs. However, I have been noticing that there is some API friction in general with having to implement message readers that then return sequences, so perhaps that should be a construct all its own and not IMessageReader<ReadOnlySequence<byte>>.
Today
IMessageReader<T>
looks like this:This works when the caller has a
ReadOnlySequence<byte>
(usually from a PipeReader) and is parsing messages at that level. Most of ourIMessageReader<T>
implementations end up creating aSequenceReader<byte>
internally over theReadOnlySequence<byte>
to do further parser.When trying to compose these parsers internally, it usually results is translating from
ReadOnlySequence<byte>
->SequenceReader<byte>
which is inefficient and inconvenient. Ideally you should be able to keep theSequenceReader<byte>
rather than switching back toReadOnlySequence<byte>
and vice versa.As an example, see https://github.com/YairHalberstadt/BedrockFramework/pull/1/files
Options:
SequenceReader<byte>
instead ofReadOnlySequence<byte>
cc @YairHalberstadt
The text was updated successfully, but these errors were encountered: