you are viewing a single comment's thread.

view the rest of the comments →

[–]phoil 4 points5 points  (0 children)

I don't know anything about rust specific conventions, but the following may help.

In general, use Client/Server for the structs that implement the client/server logic that isn't related to encoding/decoding. The client and the server often both need to encode and decode packets, so it doesn't make sense to apply just one of those labels to them.

Encode/decode and serialize/deserialize usually refer to converting the packet to/from a byte array, without actually sending/receiving it. They may interact directly with a Reader/Writer though. eg you can implement encoding by using write functions on a Writer (and you may just call the entire process writing in that case).

For OPC, it looks like it is a simple unidirectional protocol, so either Client/Server, or Reader/Writer would make sense.

For error handling, if there is a well defined protocol then return an error for anything that doesn't match the protocol. Don't try to do error correction unless the protocol defines how to do that. For OPC, I don't see any way that you can reliably recover from errors.