module Net::SCP::Download

def read_data_state(channel)

the state machine switches to #finish_read_state.
be read. As soon as there is no more data to read for the current file,
Reads data from the channel for as long as there is data remaining to
def read_data_state(channel)
  return if channel[:buffer].empty?
  data = channel[:buffer].read!(channel[:remaining])
  channel[:io].write(data)
  channel[:remaining] -= data.length
  progress_callback(channel, channel[:file][:name], channel[:file][:size] - channel[:remaining], channel[:file][:size])
  await_response(channel, :finish_read) if channel[:remaining] <= 0
end