rustbus
rustbus copied to clipboard
[WIP] avoid iterating over buffer twice
Basically make it more generic for a possible future TcpSocket impl.
Avoid going over the buffer in read_message twice. BufReader currently defaults to 8KB so it might make sense to limit this using with_capacity not sure what a reasonable default is here.
Still have to check whether this actually checks for the same line end characters as previously and as defined in the dbus spec.
I think the difference is that BufReader.read_line matches both \n and \r\n.
The docs say it only splits on \n. This is probably ok but it requires fiddling with the \r and is not quite to the dbus spec. I like the generic Read+Write argument though. Could you reverse the BufferedReader parts?
It also could be problematic if the BufferedReader read some data from the stream that is not part of the auth communication (Which probably cant happen on the client side but on the server side, which could be interesting to implement too one day)