You are browsing as a guest. Sign up (or log in) to start making projects!

2h 0m logged

Refactor client to use typed ClientMessage/ServerMessage enums and protocol builders

Replace raw struct construction and manual frame encoding in the archive,
restore, and status methods with protocol builder functions and typed
message enums. archive_project now calls protocol::build_archive_request
and protocol::build_archive_complete. restore_project uses
protocol::build_restore_request. The send_client_msg and recv_server_msg
helpers replace the generic send_frame and recv_frame functions, providing
type-safe serialization for ClientMessage enums and typed deserialization
via protocol::decode_server_message for ServerMessage responses.

The handshake function is updated to construct the Handshake message as a
ClientMessage::Handshake variant and match the response as a
ServerMessage::HandshakeAck variant, with error handling for
ServerMessage::Error responses. Response parsing in all methods uses match
on ServerMessage variants instead of serde_json::from_slice with unwrapped
payloads, catching unexpected message types at the call site rather than
failing silently with deserialization errors.

The import list is reduced from a wildcard protocol::* to explicit imports
for ClientMessage, Handshake, ProjectInfo, ServerMessage, and the protocol
module itself for builder function access.

0
2

Comments 0

No comments yet. Be the first!