Skip to main content

Module protocol

Module protocol 

Source

Structs§

Client
A higher-level client wrapper that provides incoming/outgoing channels and a graceful shutdown handle for the background connection task.

Enums§

Command
Command enum representing the app-level commands.
Response
Simple response representation. Ok may contain an optional payload string.

Functions§

connect_with_auth
Attempt to connect to addr, send the api_key followed by a newline, and return the established TcpStream if successful.
connect_with_retry
Try connecting with retries and delay between attempts.
format_command
Format a Command into a single-line string suitable for sending to the server.
format_response
Format a Response back to a line.
parse_command
Parse an incoming command line into Command. Errors are returned as server-style strings like ERROR missing_argument.
parse_response
Parse a server response line into Response.
send_command
Send a single Command over the provided TcpStream (adds a trailing newline).
start_long_lived_tcp
Start a background task that maintains a long-lived TCP connection to addr, authenticates with api_key, forwards received lines to the returned mpsc::Receiver<String>, and accepts outgoing Commands via the returned mpsc::Sender<Command>. The task will attempt reconnection on disconnect.