Function read_write_loop
async fn read_write_loop(
api: &dyn WindowsApi,
named_pipe_client: &NamedPipeClient,
internal_buffer: &mut Vec<u8>,
state_sender: &Sender<ClientState>,
highlight_sender: &Sender<bool>,
) -> ReadWriteResultExpand description
Read all available daemon-to-client messages from the named pipe and apply them.
Input records are written to the console input buffer using the provided API
and their key-event payloads are returned via ReadWriteResult::Success so
the caller can detect the Alt+Shift+C close combination. State-change frames
are forwarded via [watch::Sender::send_replace] on state_sender, making the
authoritative ClientState visible to every watch subscriber (currently
the visuals task in main) without coupling this loop to any
state-dependent rendering. Keep-alive frames are ignored. Partial trailing
frames are returned as remainder for the next call to prepend.
§Arguments
api- The Windows API implementation to use.named_pipe_client- The Windows named pipe client that has successfully connected to the named pipe created by the daemon.internal_buffer- Vector containing the unconsumed bytes (possibly an incomplete trailing frame) from a previous call.state_sender- Watch sender used to broadcast everyDaemonToClientMessage::StateChangepayload as the client’s authoritativeClientState.highlight_sender- Watch sender used to broadcast everyDaemonToClientMessage::Highlightpayload as the client’s current highlight flag.
§Returns
A ReadWriteResult indicating whether we were able to read from the named pipe and write the available INPUT_RECORDs
to the console input buffer or not.