rustbus icon indicating copy to clipboard operation
rustbus copied to clipboard

[WIP] avoid iterating over buffer twice

Open marcelbuesing opened this issue 5 years ago • 3 comments

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.

marcelbuesing avatar Feb 04 '20 14:02 marcelbuesing

Still have to check whether this actually checks for the same line end characters as previously and as defined in the dbus spec.

marcelbuesing avatar Feb 04 '20 14:02 marcelbuesing

I think the difference is that BufReader.read_line matches both \n and \r\n.

marcelbuesing avatar Feb 04 '20 14:02 marcelbuesing

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)

KillingSpark avatar Feb 06 '20 07:02 KillingSpark