I have my own serializer. After receiving the data over the network the data is in the DataStreamReader. I would like to get it and use in my own serializer. To do so I need to get the bytes from DataStreamReader.
I know I can use ReadBytes() or ReadBytesUnsafe() but then the data will have to be copied, which I would prefer to avoid to get better performance. I saw that there were some extension methods available in the past that would allow me to do what I want, but looks like they were removed.
Is there any way to access the buffer directly? If not in the DataStreamReader, then maybe there is a way to access it in the NetDriver itself?
What extension methods are you referring to? My understanding is that there is no way to directly access the backing memory of a DataStreamReader, and that this is on purpose to avoid giving direct memory access to NetworkDriver internals. But perhaps there was an escape hatch for this at some point and this was lost in the transition of these data structures to the collections package.
These APIs were removed in 2019. Currently we don’t plan on adding any similar functionality on the transport side. The team responsible for the collections package (where these types now live) might consider adding such a feature however, since they do have similar APIs for their native containers. I guess the best place to reach them would be the ECS forum. You could also submit the idea on the DOTS roadmap.