read_write_loop

Function read_write_loop 

async fn read_write_loop(
    api: &dyn WindowsApi,
    named_pipe_client: &NamedPipeClient,
    internal_buffer: &mut Vec<u8>,
) -> ReadWriteResult
Expand description

Read all available [INPUT_RECORD_0] from the named pipe and write them to the console input buffer using the provided API.

This function also extracts the [KEY_EVENT_RECORD]s, making them available to the caller via ReadWriteResult::Success and handles incomple reads from the named pipe via the internal buffer.

The daemon might send a “keep alive packet”, which is just SERIALIZED_INPUT_RECORD_0_LENGTH bytes of 1s, we ignore this.

§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 incomplete SERIALIZED_INPUT_RECORD_0 sequences that were read in a previous call.

§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.